In the javascript button below (Salesforce classic) I would like to allow users to proceed only if a selected status is active. Also for a specific user profile, I would like to not allow to proceed if the record is too old:


if ({!IF(ISPICKVAL(SBQQ__Quote__c.SBQQ__Status__c, "Status1") ||
ISPICKVAL(SBQQ__Quote__c.SBQQ__Status__c, "Status2") ||
ISPICKVAL(SBQQ__Quote__c.SBQQ__Status__c, "Status3") ||
ISPICKVAL(SBQQ__Quote__c.SBQQ__Status__c, "Status4"), false, true)})
 alert("Proceed only if status 1, 2, 3 or 4");
else if ({!IF(DATEVALUE(SBQQ__Quote__c.CreatedDate) > DATEVALUE("2019-10-15") && "$User.ProfileId" = "00e200000000000", false, true)})
  alert("Cannot proceed if date is earlier than 2019-10-15");
} else {
window.location = "/500";

Would be great if I can have some assistance on this. Thanks!

  • What are you trying to do? Convert this to Lightning? Are you getting an error here? How can we assist you?
    – sfdcfox
    Jul 21, 2020 at 19:08
  • It is a javascript button which is not working. I will not allow the user to proceed and create a new case if the conditions are met. In the example above, there are 2 validations, if the quote status is not Status1, Status2, Status3, Status4 then the alert message "Proceed only if status 1, 2, 3 or 4" should be displayed. The second validation will not allow the user to proceed if the user profile id is 00e200000000000 and the record has been created before 2019-10-15. In that case the alert "Cannot proceed if date is earlier than 2019-10-15" should be displayed, else create a new case.
    – Leo
    Jul 21, 2020 at 19:16

1 Answer 1


$User.ProfileId should not be in quotes ("$User.ProfileId" = "00e200000000000" is guaranteed to be false), and the > should be <.

else if ({!DATEVALUE(SBQQ__Quote__c.CreatedDate) < DATEVALUE("2019-10-15") && $User.ProfileId = "00e200000000000"})

Also, =, ||, and && already return Boolean values. You do not need to use an IF statement in these cases. I feel like you may not properly understand Boolean logic, so you may want to do some research on Boolean Truth Tables.

  • Thanks it is now working.
    – Leo
    Jul 21, 2020 at 19:49

Not the answer you're looking for? Browse other questions tagged .