locked
Javascript - IF and ELSE functionality OR Run Javascript from a workflow - Dilemma RRS feed

  • Question

  • I'm not an expert on Javascript but I have been able to work with other people's codes as a guide (thank you all).

    I have a need for Java to detect whether a picklist on my entity (Campaign) is selected as "Sold Out" which will then run a bit of Java (I've got that bit working fine) but if the picklist "Sold Out" is not selected it ignores the bit I would like to run and carry on processing other Javascripts on my onload event.

    In my Sinclair ZX81 Days it would read something like:

     10  IF Status <> "Sold Out" Then

    20   Go to 40

    30  Run My Code

    40 Carry on with the rest of my code 

     

    My other option is to run My Code via a workflow (if indeed that is possible) but I've seen any posts/blogs on how to do this but I have seen plenty of posts on running a workflow from Java which isn't what I need.

    Any views or code would be appreciated.

    Jim 

     

     

     

     

     

     

    • Edited by Jimbo64 Wednesday, May 26, 2010 8:06 PM Clarification
    Wednesday, May 26, 2010 8:02 PM

Answers

  • Hi in  order  to check  for  selected picklist text, you  can  do  something like this.

    if(crmForm.all.yourpicklistfieldname.SelectedText  == "Sold Out")

    {

    Your  code goes here.

    }

    else

    {

    Your  other  code if sold out  is not selectes  goes here.

    }


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Wednesday, May 26, 2010 8:35 PM
  • This should work.  Replace picklistid with the id of your picklist attribute.

    if (crmForm.all.picklistid.SelectedText == "Sold Out")
    {
        // Run My Code
    }

    Blake Scarlavai - http://mscrmdev.blogspot.com/ - Sonoma Partners - http://www.sonomapartners.com/
    • Marked as answer by Jim Glass Jr Tuesday, June 1, 2010 4:48 PM
    Wednesday, May 26, 2010 8:37 PM

All replies

  • Hi in  order  to check  for  selected picklist text, you  can  do  something like this.

    if(crmForm.all.yourpicklistfieldname.SelectedText  == "Sold Out")

    {

    Your  code goes here.

    }

    else

    {

    Your  other  code if sold out  is not selectes  goes here.

    }


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Wednesday, May 26, 2010 8:35 PM
  • This should work.  Replace picklistid with the id of your picklist attribute.

    if (crmForm.all.picklistid.SelectedText == "Sold Out")
    {
        // Run My Code
    }

    Blake Scarlavai - http://mscrmdev.blogspot.com/ - Sonoma Partners - http://www.sonomapartners.com/
    • Marked as answer by Jim Glass Jr Tuesday, June 1, 2010 4:48 PM
    Wednesday, May 26, 2010 8:37 PM