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.


1 Answer 1


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! Commented Nov 20, 2017 at 17:18
  • 1
    Yeah because if ('false') { ... } will fire. It needs to be if (false).
    – Adrian Larson
    Commented Nov 20, 2017 at 17:32

You must log in to answer this question.

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