I'm trying to use the ISPICKVAL
formula on a Visualforce page. I've assumed that doing so is better than just a straight text compare, since it will continue to work after the picklist entries have been translated (and maybe that's a big assumption).
Anyway, it's documented in the Visualforce Developer's Guide thusly:
Determines if the value of a picklist field is equal to a text literal you specify.
ISPICKVAL(picklist_field, text_literal) and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literal cannot be a merge field or the result of a function.
Sounds great, but when I try this syntax in my Visualforce page (with a standardController of My_Object__c):
{!ISPICKVAL(My_Object__c.Status__c, 'Inactive')}
I get the following error:
Save error: Incorrect parameter type for function 'ISPICKVAL()'. Expected Picklist, received Text
The Status__c
field is definitely a picklist, and 'Inactive'
is one of the options.
What am I doing wrong? And should I just give up and replace it with My_Object__c.Status__c == 'Inactive'
(which I expect would stop working if that field is translated, but maybe I'm wrong)?
ISPICKVAL($User.UserType,'Guest')
.