function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David HollandDavid Holland 

If then else statement returning Syntax Error.

Hi everyone.

 

I am creating a VF Page and displaying number merge fields.

 

<apex:pageBlockSectionItem >
<apex:outputText styleClass="dataInput" value="{0, number, ###,###,###}">
<apex:param value="{!Performance_Projection__c.L_Cap_Inv_Am_A__c}"/>
</apex:outputText>
</apex:pageBlockSectionItem>

 

I am trying to do:

 

 {!Performance_Projection__c.L_Cap_Inv_Am_P__c==0?10:5}

 

But am receiving 'Error: Syntax error'

 

I am sure it is a simple syntax error and I just can't see how I am going wrong

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You don't have the ternary operator in merge (formula) syntax, you can only use that in Apex code.

 

In the page you can just use the IF function:

 

{!IF (Performance_Projection__c.L_Cap_Inv_Am_P__c==0, 10, 5)}

 

:

 

 

All Answers

bob_buzzardbob_buzzard

You don't have the ternary operator in merge (formula) syntax, you can only use that in Apex code.

 

In the page you can just use the IF function:

 

{!IF (Performance_Projection__c.L_Cap_Inv_Am_P__c==0, 10, 5)}

 

:

 

 

This was selected as the best answer
BharathimohanBharathimohan

Hi,

 

Yes. Bob is correct ..as always :)

 

 

Thanks,

Bharathi

Salesforce For All