function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TabithaTabitha 

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?

Best Answer chosen by Admin (Salesforce Developers) 
TabithaTabitha

I was able to use this syntax successfully:

 

<apex:pageBlockSection rendered="{!Digital_Asset__c.Asset_Type__c=='Publications'}">

 

I still don't get why ISPICKVAL doesn't work, but this accomplishes what I was aiming for.

All Answers

MattLacey.ax1065MattLacey.ax1065

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:

 

rendered="{!IF(ISPICKVAL(Digital_Asset__c.Asset_Type__c, 'Publications'), true, false)}"

 Doesn't make much sense, I know, but there is a bug in there somewhere which means you sometimes require the IF.

TabithaTabitha

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).

TabithaTabitha

I was able to use this syntax successfully:

 

<apex:pageBlockSection rendered="{!Digital_Asset__c.Asset_Type__c=='Publications'}">

 

I still don't get why ISPICKVAL doesn't work, but this accomplishes what I was aiming for.

This was selected as the best answer
MattLacey.ax1065MattLacey.ax1065

Yeah that's pretty weird, sounds like some kind of bug to me. Glad you got it working though.

GeniuanGeniuan
Any word from Salesforce techs??? This is something that has to be fixed.
Edward Yerke-RobinsEdward Yerke-Robins
Had the same problem with what I’ve been working on today...
 
<apex:outputPanel rendered="{! ISPICKVAL(opportunity.Application_Group__c, 'Domestic')}">
      Domestic Application Answers</apex:outputPanel>

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
 
<apex:outputPanel rendered="{! ISPICKVAL({! opportunity.Application_Group__c}, 'Domestic')}">
      Domestic Application Answers</apex:outputPanel>

Returns simply “Syntax error”

Tabitha’s workaround works (thank you!)...
 
<apex:outputPanel rendered="{! opportunity.Application_Group__c = 'Domestic'}">
      Domestic Application Answers</apex:outputPanel>

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...

Field Information for my custom Application Group picklist.
Mike ArthurMike Arthur
I'm still getting “Error: Incorrect parameter type for function 'ISPICKVAL()'. Expected Picklist, received Text” in 2020 :-o