June 29, 2019

How to use ternary operator in Visualforce page?

Visualforce page doesn't support ternary operator. But, Apex support.

Visualforce page supports IF function. We can achieve the same using this.


IF ( logical_test, value_if_true, value_if_false )


{! IF( Account.Size__c == null, '10', Account.Size__c ) }

In the above example, if the Account's Size is null, it will default to 10. Else, it will display the Account's size.

No comments:

Post a Comment