For some reason this if statement is always triggering regardless of if the criteria is met or not.


     alert("This event has already been completed");

So beforehand I am printing out the value and this shows false - when I am running my current example. For some reason even when false is printed out the code enters the if statement and prints out "This event has already been completed". Anyone run into something like this before?

Edit 1:

I made the modification to the code and am still entering the if statement with the same test.

 alert("This event has already been completed");
  • 3
    Try removing the quotation marks. – PepeFloyd Mar 28 '14 at 13:37

It may be because it is treated "false" as a string and that's why




So you can try to do it like that

   var isCheck ="{!ISPICKVAL(Resolution_Event__c.Schedule_Status__c,'Scheduled')}";
   alert(ischeck);// must show correct value (either true or false)
   if(ischeck== "false"){
   alert("This event has already been completed"); 

I guess it may help you.

  • No I don't believe this is the case as when I type the code. "{!ISPICKVAL(Resolution_Event__c.Schedule_Status__c,'Scheduled') == 'true'}" I receive an error telling me that it expected a boolean but found text – Chris Mar 28 '14 at 13:47
  • Removing the quotation marks resolved the issue, thank you both. – Chris Mar 28 '14 at 13:55
  • As recommended we need to pass the Salesforce variables within quotes if accessing from JavaScript so it would be possible to receive "true" when passing within quotes. I have faced almost same flaw in past, i tried to make use of temporary variables (using var) of JavaScript and then conditionally check value of these variables instead of sf variables. – userRg Mar 28 '14 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.