0

I am having difficulty creating a formula that would remove the semicolon from Salesforce Multi-Select picklist values to a comma.

Basically I want "A;B;C" to appear as "A,B,C"

I tried using a formula below but it did not work out as I intended:

IF(INCLUDES(myMultiSelectPicklistfield_c, ";"), "," , "")

Any suggestions are really appreciated

1 Answer 1

3

You can only use the following functions with Multi-Select Picklist fields:

  • INCLUDES
  • ISBLANK
  • ISNULL
  • ISCHANGED (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited )
  • PRIORVALUE (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited )

None of these really work for substitution, unless you want to pursue a really ugly concatenation scheme using IF(INCLUDES(Multiselect__c), "a,", "") & IF(INCLUDES(...), "...", ""). In addition to being ugly, this formula would likely exceed character limits, and you have to deal with the trailing comma somehow.

However, it would be fairly straightforward in a before trigger.

for (MyObject__c record : trigger.new)
{
    if (record.Multiselect__c != null)
    {
        record.SecondField__c = record.Multiselect__c.replace(';', ',');
    }
}

You should question what you are really trying to achieve with this secondary field. There may be alternative, simpler means.

If you pursue an Apex Trigger, you should read up carefully on Trigger Frameworks and Apex Trigger Best Practices.

2
  • Is there any way to replace the semicolon by comma in the multiselect picklist field itself rather than other field?
    – Shilpa
    Apr 4, 2018 at 7:25
  • No there is not.
    – Adrian Larson
    Apr 4, 2018 at 13:29

You must log in to answer this question.

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