Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a third apex class Class3 that needs to be applied for a conditional statement in visualforce Status__c == 'In Progress'. This is my code.

 styleClass="{!IF(account.Status__c == 'Closed','Class1','Class2')}"/>

Basically I'm coloring the Status fields according to its value. I have tried with else condition. Doesn't work. Is there any way to fit in the third apex class? Thanks

share|improve this question
up vote 4 down vote accepted
 styleClass="{!IF(account.Status__c == 'Closed','Class1', IF(account.Status__c == 'In Progress','Class2', 'Class3'))}"
share|improve this answer
Working perfectly! Thanks. – MnZ Apr 16 '14 at 14:05

Another approach is to use the CASE formula which is a little clearer for this sort of matching:

...="{!CASE(account.Status__c, 'Closed', 'Class1', 'In Progress', 'Class2', 'Class3')}"/>
share|improve this answer
I used the styleClass attribute in <apex:column>. Can I use case as <apex:column value="{!CASE(account.Status__c, 'Closed', 'Class1', 'In Progress', 'Class2', 'Class3')}"/> too? Will be handy :) – MnZ Apr 16 '14 at 14:09
@MnZ Yes you can use this in other places to set styleClass. But your comment has value: you can use conditional logic for the value too but presumably would not be class names. – Keith C Apr 16 '14 at 14:44
Thanks @keith-c, I will surely try the CASE formula :) – MnZ Apr 16 '14 at 14:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.