0

I'm using Visualforce page to make it an Export template so that when user press a button, it will export data from List View.

Everything is fine but I have a problem with multi-select picklist. Because API values are different from values display in UI so I have to typecast it.

What I tried:

<td>
         <apex:outputText value="{!IF(acc.multi_select_picklist = '1', 'First Item', '')}" />
         <apex:outputText value="{!IF(acc.multi_select_picklist = '2', 'Second Item', '')}" />
         <apex:outputText value="{!IF(acc.multi_select_picklist = '3', 'Third Item', '')}" />
</td>

It works okay when user choose only 1 value. But when user choose up to 2 values, it displays empty. Is there any way I can work on this?

Best Regards,

Pam.

1 Answer 1

1

To work with multi-select picklists (MSP), you can't use the = operator in formula expressions. You need to use the INCLUDES function

<apex:outputText value="{!IF(INCLUDES(acc.multi_select_picklist,'1'), 'First Item', NULL)}" />
<apex:outputText value="{!IF(INCLUDES(acc.multi_select_picklist,'2'), 'Second Item', NULL)}" />
<apex:outputText value="{!IF(INCLUDES(acc.multi_select_picklist,'3'), 'Third Item', NULL)}" />

Note the use of NULL rather than '' which is a bit cleaner

1
  • Hi @cropredy, thank you so much for your idea! Somehow, the INCLUDES did not work so I tried to replace it with CONTAINS and it works!
    – Pam
    Commented Feb 4, 2023 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .