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

Error Using ForEach Collections from SharePoint List multivalue choice field

I'm new to using Nintex but I think I have everything right that's obvious but its not working and I'm getting frustrated.  I have a simple list that has a multi-value choice field (checkboxes).  In my workflow, I want to get the selected choices from the item, cycle through each one and send an email or do other actions per value.  So like this:

Assign Current Item: Category to Collection

Count collection

If 0, add a stnd value to the collection of index 0

else count >0, continue

foreach value in the collection

     Run on collection variable

     Output variable is TEXT variable "EachCategory"

     Output index variable is integer "EachCategoryIdx"

Get item from collection

     index of item to get - "EachCategoryIdx

     output item to variable - "EachCategory" (I've tried creating a separate one too)

Log to history

     Value: "EachCategory"

The workflow goes Suspended with the error "An unhandled exception occurred during the execution of the workflow instance. Exception details: System.FormatException: Input string was not in a correct format.   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal"

If I remove the get item from collection, it doesn't error but I can't get the text label of the choice value.  So there's some type of mismatch, but what gives?  the value should be text right?  It's like it's trying to output the value as the integer or something.  Ok I just changed the get item from collection output to a integer variable and that errored too.  Am I doing something stupid wrong, or is this a bug?

I dumped the count and collection to the history, and it shows this: Count: 2; Collection: {"__metadata":{"type":"Collection(Edm.String)"},"results":["Blog","Video"]}.  What I need is to get the "Blog" and "Video" values.

Any help would be appreciated - Doug

Labels: (1)
Reply
12 Replies
Workflow Hero

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

Hi Doug,

If you are stuck, there is a Javascript alternative

get checkbox value with javascript Re: get checkbox value with javascript

Regards,

Christophe

Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

Hi Doug,

I have some difficulty understanding your exact problem. If I understand you correctly you have a collection with (at least in your example) 2 values in a collection. If you use a "for each"-action you feed your collection to that action and it'll give you each value from your collection at a time. It'll get stored in whatever variable you use for the "Output value" configuration option within the "for each"-action.

Why do you need the "get item from collection"-action at all? Wouldn't it be possible to use the output value?

Regards

Timo

Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

Timo, that's correct.  I am new to Nintex so I'm not 100% sure, but as I understand it, this is different than in on prem where everything was in 1 action.  In 365, they broke out all the collection stuff into separate actions you have to use.  Besides, I tried it without and it didn't work.  I dumped the value of EachCategory in the log, and it was null.  So I think I have to get it separately.

Even forget the get item from collection for a minute.  On the foreach, I give it a variable for the Value and Index of each item.  If I don't specify an index, I get no error (but without the index, I can't get the value anyway).  If I specify the index variable, it blows with the error.

Accept as Solution Reply
Workflow Hero

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

When you log the values of the SP column, you get {"__metadata":{"type":"Collection(Edm.String)"},"results":["Blog","Video"]}.

Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

That's the output of the COLLECTION.  I need to get each one (Blog and Video) separately.  When I dump this variable (EachCategory) in the foreach, its null.

Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

Hi Doug,

thank you for your clarification. I do not think you'll be needing the "get item"-action. I just tried it on O365, here is what I have done:

1.) Manually add two values to an empty collection to have a test collection. Obviously you'll have some logic there but I just added two strings by using two "Add item to collection"-actions. I configured them as shown here:

2016-03-07 15_42_56-Start.png

2.) Next I added a "For each"-action and configured it as shown here:

2016-03-07 15_44_07-Start.png

3.) Within the "For each"-loop I just added a "log to history"-action to log the value retrieved in the "For each"-action:

2016-03-07 15_45_59-Start.png

The complete "For each"-Loop looks like this:

2016-03-07 15_48_03-Start.png

So, from within the "For each"-loop I have access to the values, I could log them just fine, which obviously means I could do anything I want to these values.

Does this help in any way?

Regards

Timo

0 Kudos
Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

That's exactly how I would expect it to work and how I tried it at first.  It might be something in how the format is of multiple choice values from the SharePoint list.  I'll do this and compare the collection output.  If they're the same, then I'm really scratching my head.

Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

I'm quite interested in your results. As you said, perhaps the collection itself is the root cause. Did you manage to test it yet? If you like can post your collection-building actions here, so I can try to reproduce the issue.

Accept as Solution Reply
Not applicable

Re: Error Using ForEach Collections from SharePoint List multivalue choice field

Well I replicated your behavior.  I created a manual collection, and that worked just fine.  As you said, it dumped the value names without issue.  When I point the collection to getting the values from the SharePoint multiple choice field, it goes suspended again.  So it has to be the collection isn't in the right format to be enumerated from that field type.  I dumped the values of the 2 different collections:

Collection built manually in workflow: ["Blog","Video"]

Collection from SharePoint list column: {"__metadata":{"type":"Collection(Edm.String)"},"results":["Blog","Video"]}

When it's the 2nd, the foreach dies with a not right format.  Sounds like a bug or not accounted for in the workflow.  Or how do I reformat or get the values from the list to make this work?  Here's my column settings:

column.PNG

Thanks for the help.

0 Kudos
Accept as Solution Reply