cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

I am trying to take a values from a multi-select checkbox and store in a collection so I can loop through them.  I was wondering if I could use a regular expression and split it, but I am not sure of the syntax.

Labels: (1)
Reply
8 Replies
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

I think it's a semicolon, but not sure. Maybe first test this by using a workflow set to start manually, and all it does is use the log to history action. In the action use a reference to the multi select field and nothing else. Run the workflow on the single item and check the value from workflow history. Then build the primary workflow using that data. Using the regular expression Split option is a great way to split values like these into collections, then use the for-each loop through that collection.

Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

It's actually just ;#

so a semicolon followed by a hash.

noteworthy that a field like that starts and ends with those. So your data could be stored as

;#optionA;#optionB;#

Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

if you need additional help to the above, this is a really good blog https://community.nintex.com/community/tech-blog/blog/2014/07/28/regular-expressions-in-nintex-workf...

Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

Great work Cassy Freeman​ and Thorsten Dehaes​!

Paul Vana​, does this help answer your question?

0 Kudos
Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

Paul Vana​,

So, I was struggling with this and finally figured it out.

Workflow actions:

  1. Action: Set workflow variable
    • Type "Text"
    • Value as list lookup, current item, to the "choice" field that you have set as checkboxes. IMPORTANT: Use advanced lookup so you can select return type. To do this, click the "fx" icon, and then choose: "Choices, comma delimited"
  2. Action: Regular Expression
    • String: The variable you set in "1"
    • String operation: "split"
    • Pattern "," (not quotes, just put a comma in that field by itself)
    • Output: A collection variable of your choosing (likely a new one)
  3. Action: For Each
    • Input dictionary or collection: The collection you created in "2"
    • Output value: A new text string of your creation
    • output index and stop processing are not needed in this example. (depending on what you intend to do in the loop)
  4. Action inside the for each: Whatever you want, but for testing, you can just log your output value (see 4, bullet 2) to the history list.

That's it. For me, it was discovering the option to bring back the return type of a choice checkbox column type. I spent HOURS trying to regex the string before discovering that.

returntype.png

Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

Great use of built in features!

Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

Just made use of this, and Nintex cleverly allows you to format the result of Lookups as well so you can choose the Lookup value or ID!

0 Kudos
Reply
Workflow Hero

Re: How can you create collection to loop through based on values from a multi-select checkbox field?

Jump to solution

With some new options now available to us, the best practice would be to store the multiselect item property into a dictionary, fetch the collection within the dictionary, then for each on the collection. This way there is no parsing work required.

Reply