You need to sign in to do that
Don't have an account?

Syntax problem with ISPICKVAL
I'm trying to use ISPICKVAL to conditionally render part of my visualforce page. I want to show a pageBlockSectionItem if the value of Asset_Type__c is "Publications". Here is my code:
<apex:inputField required="true" value="{!Digital_Asset__c.Asset_Type__c}" /> <apex:pageBlockSectionItem rendered="{!ISPICKVAL(Asset_Type__c, 'Publications')}"><apex:inputField required="true" value="{!Digital_Asset__c.Publication_Title__c}" /></apex:pageBlockSectionItem>
The error I'm getting is:
Error: Unknown property 'Digital_Asset__cStandardController.Asset_Type__c'
I've also tried using {!ISPICKVAL(Digital_Asset__c.Asset_Type__c, 'Publications')} in the rendered block, but then I get: Error: Incorrect parameter for function 'ISPICKVAL()'. Expected Picklist, received Text.
What am I missing here?
I was able to use this syntax successfully:
I still don't get why ISPICKVAL doesn't work, but this accomplishes what I was aiming for.
All Answers
The latter is definitely the correct approach, it sounds as though Asset_Type__c isn't actually a picklist, I can't see any other reason as to why that would generate the error it is.
Additionally, one thing to be wary of is that sometimes using a boolean function in a rendered block doesn't work correctly (though it doesn't throw an error), you may need to do this as well:
Doesn't make much sense, I know, but there is a bug in there somewhere which means you sometimes require the IF.
Asset_Type__c is most definitely a picklist. I've tried it with the IF as well, and I still get the same error (Incorrect parameter for function 'ISPICKVAL()'. Expected Picklist, received Text).
I was able to use this syntax successfully:
I still don't get why ISPICKVAL doesn't work, but this accomplishes what I was aiming for.
Yeah that's pretty weird, sounds like some kind of bug to me. Glad you got it working though.
Returns “Error: Incorrect parameter type for function 'ISPICKVAL()'. Expected Picklist, received Text”
I thought it was a newb mistake of forgetting to put {! } around a Salesforce field, yet
Returns simply “Syntax error”
Tabitha’s workaround works (thank you!)...
But I don’t like not knowing why something isn’t working (it’s my understanding that picklists require ISPICKVAL() or TEXT() functions to be used in formulas). As this is my very first Visualforce project I don’t know if it’s human error or mechanical bug. The field is definitely a picklist...