-1

I am trying to set up a flow to send an email to newsletter subscribers in a custom object (Newsletter) filtered by industry.

Currently industry is a picklist field, not a multi-select picklist, though I could change that if it would somehow circumvent the problem I have outlined below.

I set up a screen at the beginning of the flow for recipient selection. It displays a checkbox group allowing the user to select multiple industries. It outputs to a screen component (Choose_recipient_by_industry).

The next step in the flow is Get Records, which is currently set up to filter Newsletter records by CONTAINS Choose_recipient_by_industry. This works perfectly when only one selection is made. When two or more boxes are selected, the flow results in an error.

I am well aware that this error is due to the limitations of the CONTAINS operator, which will only filter for records that contain all of the selected industries. This would still be a problem if I changed industry to a multi-select picklist.

What is the simplest way to set up this functionality?

1 Answer 1

0

The best way to achieve this is to loop through the selected values in the Checkbox Group you're using to split these values into a collection of Strings which can then be used with a Get Records node using the 'IN' operator.

There's a great help article for this use case available here (noting that this is using a Multi-Select Picklist, but that doesn't change the solution for you): Loop through multi-select picklist values in screen flow without using apex

To quickly summarise this:

  1. Create a variable to store the selected values
  2. Assign the selected values plus an ';' to this variable
  3. Create a formula to find the first value in the selected values, using the fact that we have ';' as a separator.
TRIM(                                                                                                         
SUBSTITUTE(
LEFT( {!SelectedIndustryValues} , FIND(";",  {!SelectedIndustryValues} )),
";",                                                                                          
NULL))
  1. Create a variable to store the single selected value that the formula provides
  2. Create a collection variable to store the separated values (this is what you'll use in your Get Records eventually)
  3. Create an Assignment to add the single value to the collection
  4. Assign an updated list of selections to the SelectedIndustryValues variable, removing the value we have just pulled out of this
  5. Check if there are any more values to assign via a decision node

The detailed steps are in the link I've added, but this should help you achieve what you're looking for.

7
  • 1
    Alternative: UnofficialSf.com Multi-select Magic; I'd also make the last arg to SUBSTITUTE NULL, not ""
    – cropredy
    Commented Aug 2, 2023 at 21:49
  • Great points, thanks @cropredy. Definitely agree on the null substitution, I've updated my answer. Commented Aug 2, 2023 at 21:57
  • It took me years to wean myself off "" in formulas after I finally realized that SFDC did the right thing when strings were NULL
    – cropredy
    Commented Aug 2, 2023 at 22:04
  • Thank you for your quick reply @CallumMacErlich. I put together the flow you suggested before realizing I will need the Winter '23 release to access the IN operator within Get Records.
    – Scott R
    Commented Aug 7, 2023 at 20:01
  • I am looking into getting that upgrade now. I will return with any questions I have once I get that worked out and finish building the flow.
    – Scott R
    Commented Aug 7, 2023 at 20:03

You must log in to answer this question.

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