Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a third class Class3 that needs to be applied for 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? Thanks

share|improve this question
add comment

2 Answers 2

up vote 3 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 at 14:05
add comment

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 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 at 14:44
    
Thanks @keith-c, I will surely try the CASE formula :) –  MnZ Apr 16 at 14:46
add comment

Your Answer

 
discard

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.