1

The requirement I have is that a multi-picklist (MSP) field ("Specialty") is updated based on any additional values from another multi-picklist field ("Specialty Marketing") with the same picklist options. This means any values on field B should be ADDED (not overwritten) to the already selected values on field A. I need to do this using Salesforce Flow and although I think I got the flow right, I am not too confident about the formula which updates the "Specialty" (varSpecialtyMSPvalue) field with values from the "Specialty Marketing (newSpecialtyMSPvalue)" values.

IF(ISBLANK({!varSpecialtyMSPvalue}),
{!newSpecialtyMSPvalue},
IF(NOT(CONTAINS({!varSpecialtyMSPvalue},{!newSpecialtyMSPvalue})),
SUBSTITUTE(SUBSTITUTE({!varSpecialtyMSPvalue},'[',''),']',';'+{!newSpecialtyMSPvalue}),
SUBSTITUTE(SUBSTITUTE({!varSpecialtyMSPvalue},'[',''),']','')
))

EDIT: The formula is correct in terms of syntax as I can run the flow but the field is overwritten instead of appended (i.e. existing values are removed and new values are added). During debug, I get the following results:

1. Successfully found record. {!varSpecialtyMSPvalue} = null

2. Update the records’ field values. EMEA_Specialty__c = {!Update_Specialty_Field} (null)

What am I missing? Thank you to whoever takes the time to give me guidance!

Below a snapshot of my flow elements for additional context: enter image description here enter image description here enter image description here enter image description here

15
  • Welcome to Salesforce Stack Exchange (SFSE)! I don't have time to test things out, and I don't know if this is still the case, but at one point in formulae you needed to use INCLUDES rather than CONTAINS for multi-select picklists. (See help.salesforce.com/s/… | salesforce.stackexchange.com/q/198532/81648). If your 2nd field does not have to be multi-select, and could be a formula field instead, you might could do this without a Flow: help.salesforce.com/s/articleView?id=000322999&type=1.
    – Moonpie
    Jul 8, 2022 at 11:57
  • Thanks for the answer. Since I need to convert the multi-picklist to text to be able to work with it in a flow, I can't use INCLUDES. Moreover, both fields need to remain a multi-picklist since I want to append additional values :)
    – Lisa.xcv
    Jul 8, 2022 at 12:08
  • So have you run this "as-is"? If so, what is the result: An error? Nothing? Unexpected result?
    – Moonpie
    Jul 8, 2022 at 13:09
  • If so (and if not, please do so, and then) please edit your question to add that information.
    – Moonpie
    Jul 8, 2022 at 13:25
  • I've edited my question accordingly - thanks!
    – Lisa.xcv
    Jul 8, 2022 at 13:35

1 Answer 1

0

As it turns out, using the UPDATE RECORDS Flow elements with a simple IF(NOT(CONTAINS formula was not possible as the multi-picklist values were not parsed and thus finding a duplicate was impossible. The challenge I had was that I had two identical Multi-Select Picklist fields ('Specialty' and 'Specialty Marketing') and the objective was that whenever the field 'Specialty Marketing' gets populated with a number of picklist values, these should be ADDED to the existing values on the Specialty field and not OVERWRITTEN. This means I had to find a way to convert both Multi-Select Picklist fields into a text collection variable so I could loop through them to identify existing values vs unique ones.

Thus, I had to completely re-invent the wheel to do the following and IT WORKS:

  1. APEX Action to firstly parse the Multi Select Picklist values of both fields: takes the Multi Select Picklist values in format [A;B;C;D] and will return two separate text collection variables in format [A,B,C,D].
  2. Now that I had two collection variables, I was able to loop through both items and compare them with another to identify if an item in the field 'Specialty Marketing' was existing in the field 'Specialty'.
  3. For each item in the first loop, I set a Boolean variable to 'FALSE' which I could later use to check if it was set to 'TRUE', given that a duplicate was found.
  4. I then looped each item my 'Specialty Marketing' text collection variable through the 'Specialty' text collection variable and put in a decision-split which checked if the current item from loop 1 (Specialty Marketing) == current item from loop 2 (Specialty). If YES = change the Boolean variable to TRUE and loop through the next item. If NO = do nothing and continue to loop through the next item.
  5. After the last item of loop 2, I then checked whether the Boolean field is currently set to FALSE. If YES = added the current item of loop 1 to a stored text variable (newList) where I was storing all of my unique values which I wanted to append to my original Multi Select Picklist (originalList) which I retrieved through the Apex Action and was stored in a text collection variable.
  6. After the last item of loop 1, I then merged the (newList) with the (originalList) by adding them in an assignment element and updated the record with that assignment output.

Here's a screenshot of the flow:Flow

1

You must log in to answer this question.

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