0

I have a syntax issue with this line of code:

<apex:sectionHeader title="{!if(!PP_IsOwner,!$Label.D1,!$Label.D2)} />

Here is the relevant line of code from the controller:

public Boolean PP_Detect {get; set;}

it returns this error:

Incorrect parameter type for function 'not()'. Expected Boolean, received Text

PP_isOwner is a boolean field, if its value is set to true then I want to display the D1 label, else D2 label.

1 Answer 1

2

Formulas in Visualforce start with {!, and end with }. Individual fields do not start with !; using ! inside the formula works as the not operator.

{!if(PP_IsOwner, $Label.D1, $Label.D2)}
3
  • I see what you mean and it does work however I do have other lines of code (without the if statement) where I reference a label with the !$ notation such as: <apex:pageBlockSection title="{!$Label.Escalation}" columns="1"> and it works, how do you explain this?
    – Json
    Dec 4, 2016 at 14:19
  • @Dante The merge field itself starts with {!. So, the formula is actually $Label.Escalation. Do not consider the opening {! and } as part of the actual formula, it simply tells Visualforce that there's an expression to evaluate.
    – sfdcfox
    Dec 4, 2016 at 14:21
  • @Dante You're welcome! Glad I could help!
    – sfdcfox
    Dec 4, 2016 at 14:23

You must log in to answer this question.

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