This is a follow-up to the original question asked by tomlogic here: Errors using ISPICKVAL on Visualforce page since I don't have enough reputation points to comment on the answers.
I am trying to develop a visualforce page that will render as a PDF document. I have some records that I need to be displayed on the page conditionally, based on the return value of an IF()
function that I want to use to check the values of a multi-select picklist field. Right now my code looks something like this:
<apex:repeat value="{!PriceBook2.PriceBookEntries}" var="p">
<apex:outputPanel styleClass="sheet-row" layout="block"
rendered="{!
IF(
AND(
ISPICKVAL(p.Product2.Product_Family__c, $CurrentPage.parameters.family),
p.Product2.IsActive == True
),
'true', 'false'
)}">
<div class="sheet-column-1">
<p class="product-name">
{!p.Product2.Short_Product_Description__c}
</p>
<p class="product-code">
({!p.ProductCode})
</p>
</div>
<div class="sheet-column-2">
{!p.Product2.Description}
</div>
<div class="sheet-column-3">
<apex:outputText value="{0, number, currency}">
<apex:param value="{!p.UnitPrice}" />
</apex:outputText>
</div>
</apex:outputPanel>
</apex:repeat>
After all these years, Salesforce still does not seem to allow us to use ISPICKVAL()
on the VF page as it's treating the values returned by field references as regular strings ("Incorrect parameter type for function 'ISPICKVAL()'. Expected Picklist, received Text").
Is there any way I can reliably check the value of a multi-select picklist in the VF page without doing some crazy hack with CONTAINS()
? I don't want to use CONTAINS()
as it may incorrectly match certain values that contain the same strings (but are still distinct values).
For example if I have the values "ABC" and "ABC123" in my picklist, and I want only records that have selected "ABC", I can't use CONTAINS(p.Product2.Product_Family__c, "ABC")
as it will also return true for the ones that have "ABC123" selected.
Is there any workaround short of using dirty javascript hacks or custom objects/apex controllers to pre-sort the records into separate lists? Note: INCLUDES
doesn't work either. "Function INCLUDES may not be used in this type of formula"