Can anyone help me with the syntax for using a custom label in a Javascript button. Essentially, I am trying to direct users to different pages based upon whether the Opportunity Record Type contains the 15 character ID string contained in a custom label. My code is below:

    if('{CONTAINS(Opportunity.RecordTypeId,$Label.ENT_CommitRT_ID)}' == 'TRUE'){


The problem is that no matter what record type the Opp has, it always defaults to else condition.


You have two notable problems with your logical evaluation:

  • You're missing the bang character (!) required in merge syntax.
  • You don't need to compare strings. Just use the Boolean output directly (if({!...})).

Instead of:

if ('{...}' = 'TRUE')
//    ^ missing !


if ({!...})
//  ^^ don't wrap in quotes
  • Thanks. For some reason, when I remove the single quotes from my initial condition, it works! – John Neilan Nov 20 '17 at 17:18
  • 1
    Yeah because if ('false') { ... } will fire. It needs to be if (false). – Adrian Larson Nov 20 '17 at 17:32

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.