You need to sign in to do that
Don't have an account?
How do I assign multiselect picklist values to a collection variable in a flow?
I have a flow where I tried to add the multiselect picklist values to a collection variable but this simply added all values as one value (e.g. "x;y;z" rather than "x";"y";"z". How do I add these as individual values to the collection so that I can use them in a loop?
All Answers
https://developer.salesforce.com/blogs/developer-relations/2012/09/visual-workflow-freedom-of-choice.html
I found a not very intuitive work-around, but it works:
- I used a fast lookup to create an sObject collection variable, which basically replicates the dynamic choice that populates the multi-select checkbox field
- After the user makes his/her choices (populating the multi-select field) I loop through the sObject collection variable
- The loop connects to a decision
- If the multi-select field contains the [sObject variable].Id (or whatever field you're using as the value of your dynamic choice)
- then ... (in my case I create a record)
- then connect back to the loop
- If the multi-select filed does not contain the [sObject variable].Id (or whatever field you're using)
- then connect back to the loop
I hope this helps. I'm happy to discuss more if what I described doesn't make sense.I came up with a solution similar to yours, but I was apparently overthinking it was I was trying to assign the multi select dynamic choice values to a collection variable first (where you can see them as semi-colon delimited IDs) and then loop the decision against that collection variable - going this route worked great as long as I only selected a single value, but any combination of multi selected values ended in no matches. So I nixed the collection variable and linked the loop decision directly against the dynamic choice as you suggested and BINGO.
I also want to echo what Joe wrote:
"Unless I'm missing something really obvious, it seems like a huge limitation to not be able to assign a multi-select field to a collection variable OR be able to loop on a multi-select field. What's the point of having a multi-select field if you have to write code to parse the values?"
+1
Thank you your solution works great. It took me some fiddling around to get it to work.
Initially in the decision I try to match against the dynamic choice does not return any matches:
But if I match against the multi-select choice field which contains the dynamic choice it worked like a treat.
Many thanks.
http://automationchampion.com/2015/02/03/add-record-to-multiple-chatter-groups-parsing-multi-select-picklist-fields-flow/
Best Regards,
Raja
Thanks.
6. Loop through the collection variable populated in step 5 and assign the current value to a new variable using the Loop element.
7. In the Record Create element, use the current value variable to assign a value to a field for the new record.
1. Ensure that your screen element stores the ID of the selected
2. After user (multi-)selects, assign the Screen Element variable to a Text variable. The Text variable will now contain all the ID's of the selected records selected (assuming the Screen element is a record choice set - but it would work for other choice sets also).
3. Use text formulas & assignment element to extract the first 18 digit ID code, and use that code in an assignment/create/lookup etc element, as needed for your code.
4. Use text formulas & assignment element to remove the retrieved ID plus semi-colon plus space from the Text variable.
5. Use a Decision element to determine if the end of the text variable has been reached (a quasi loop), and either return to 3 again, or exit.
Try you will lioke https://www.slotozilla.com/free-slots/kitty-glitter it really good
I was trying to update one field on several records that the user selects from a multi-select picklist. Joe's solution worked. I did 2 assignments in the loop, one to update the field I want, and another to assign the record from the current loop to a third collection variable. Then I did an "update records" on that third collection variable.
Worked like a charm! Thanks again.
Usually technicians work with almost any company, the company I work for has them, you can contact them by going to the company website. I leave the link here 7bitcasinoreview.com
What it does is get the length of the string of Picklistvalues and subtract the length of the string of Picklistvalues where the separation character of the values ";" is replaced by an empty string "" and adds 1
Example1:
Picklist choice value = "Choice1"
Length of "Choice1" = 7 (a)
Length of "Choice1" where ";" in "Choice1" was replaced by "" = 7 (b) (it was not found so there was nothing to replace)
Add 1
a - b + 1 = 7 - 7 + 1 = 1
There is 1 choice selected
Example2:
Picklist choice value = "Choice3;Choice4;Choice6;Choice9"
Length of "Choice3;Choice4;Choice6;Choice9" = 31 (a)
Length of "Choice3Choice4Choice6Choice9" where ";" in "Choice3;Choice4;Choice6;Choice9" was replaced by "" = 28 (b)
Add 1
a - b + 1 = 31 - 28 + 1 = 4
There are 4 choices selected
When you add a choice from your picklist to a record variable and recordcollection variable, you want to count the added choices so you can stop adding choices when the number of added choices is eqal to the number of selected choices.
For this you create a variable, type number, no decimals and give it a name like "NumberOfProcessedChoices". Default value 0
Create another variable, type Text, and name this like "AddedChoices"
Create a formula, type Text, Name "ChoicesToProcess". Formula: IF( LEFT( RIGHT( {!Picklist}, LEN( {!Picklist} ) - LEN( {!AddedChoices} ) ),1) = ';' ,
RIGHT( {!Picklist}, LEN( {!Picklist} ) - LEN( {!AddedChoices} )-1),
RIGHT( {!Picklist}, LEN( {!Picklist} ) - LEN( {!AddedChoices} ) ) )
Create a formula, type text, Name "ChoiceToProcess". Formula: If( FIND( ';' , {!ChoicesToProcess}) = 0, {!ChoicesToProcess}, left( {!ChoicesToProcess} , find( ';' , {!ChoicesToProcess} ) -1)) )
Create a formula, type Text, Name "AddChoice". Formula: If( LEN( {!AddedChoices} ) = 0, {!ChoiceToProcess}, {!AddedChoices} + ";" + {!ChoiceToProcess} )
In your flow, before you start adding choices from your picklist to a record variable and recordcollection variable it's a good thing to:
- assign the value 0 (again) to this variabe ("NumberOfProcessedChoices")
- assign the value emptystring to this variabe ("AddedChoices")
Create a variable, type Record, checkbox "allow multiple values" NOT checked, choose the object where you want your choice to be added to, let's say you name it "SingleChoiceRecord"
Create a variable, type Record, checkbox "allow multiple values" MUST BE checked, let's say you name it "ChoicesRecordCollection"
After the assignment you add a decision, let's say you call this "CheckNumbersToProcess". When "NumberOfProcessedChoices" LES THEN "NumberOfChoices" then go to
Assign the needed fields AND your formula "ChoiceToProcess" to the corresponding fields in your record variable "SingleChoiceRecord",
then you ADD this recordvariable "SingleChoiceRecord" to the recordCollection Variable "ChoicesRecordCollection"
After this you add an assign element:
- Assign a new value to the variable "NumberOfProcessedChoices" -> ADD -> 1
- Assign a new value to the variable "AddedChoices" -> Equals -> your variable "AddChoice"
Go back to the decision "CheckNumbersToProcess". When "NumberOfProcessedChoices" is still less then "NumberOfChoices" it will add the next choice, and so on
When "NumberOfProcessedChoices" is equal to "NumberOfChoices" you create the records from the recordcollection