StratusForms icon indicating copy to clipboard operation
StratusForms copied to clipboard

Multi select choice field as check boxes

Open btroop202 opened this issue 6 years ago • 5 comments

The customer wants to have a list of location and on the form have them display as check boxes. Think a choice field in SP where you select checkboxes (allow multiple selections). Does anyone have an example of this working so I can see how you got it to work. I also will need to save this in a SP col that I can filter by location.

btroop202 avatar Aug 15 '18 09:08 btroop202

Or better yet, how can I take the JSON data from a multi select list, and put it in a choice field. I am trying to do it with a workflow but having issues. The plan was to put the StratusForm value in to a text column, then using a workflow set the choice filed that has the same options as the select field.

This would be great if I can get this to work

Thanks, ahead of time

btroop202 avatar Aug 16 '18 12:08 btroop202

Good day, Wow this was a pain

Set value of a multi choice field using a SharePoint workflow

First we have to look at what is the real data stored in the SP list for the choice field: {"__metadata":{"type":"Collection(Edm.String)"},"results":["Belgium","Cyprus"]} -- In this case I have a list of countries, as you can see Belgium and Cyprus were selected

I am using StratusForms, and in a string field it stores: Belgium;#Cyprus in the list I have another col which is the choice field of countries (in this case both list need to be the same)

Now for the fun part, and once you see it you will see how easy it is…like magic

In your SP 2103 workflow Create some local variables (all type string): lChoiceField lStart lEnd lFinal lMid

Set lStart to: {"__metadata":{"type":"Collection(Edm.String)"},"results":[" Set lEnd to: "]} Now let’s set lChoiceField equal to my string (Belgium;#Cyprus) Now for the logic IF lChoiceField contains ;# -- (Belgium;#Cyprus) need to do a find and replace on ;# Replace ;# with “,” in lChoiceField (output to Variable: lMid) - in this example we now will have Belgium”,”Cyprus Else Set lMid to lChoiceField - Only one option in the list was selected Set lFinal equal to [lStart][lMid][lEnd] - lFinal should look like this {"__metadata":{"type":"Collection(Edm.String)"},"results":["Belgium","Cyprus"]}

Finally set the field in the current item to lFinal….. and BAMM!!!

Why did I need to do this? Great question, in this example if I wanted to use SharePoint to filter all records from a country, I can use built in SP logic. As I had it in a string it would not work.

Let me know if you have any questions or suggestions

Thanks, Darrin

btroop202 avatar Aug 16 '18 14:08 btroop202

All i can say is.. yeah... multi choices are a pain :)

mrackley avatar Aug 16 '18 14:08 mrackley

Forgot to add, make sure the choice list is set to 'Checkboxes (allow multiple selections)' otherwise this method does not work.

btroop202 avatar Aug 17 '18 12:08 btroop202

@btroop202

Do you have any idea on this problem for check boxes? I have multiple of check boxes and user is able to have multiple selections. But Stratus forms save "0" in my list, I need the selected values to be in SP list in a text column. how can I pass the values of the selected checkboxes to ListFieldName?

Any modification in java or html?

part of html: `<input ListFieldName="Request" name="Request1" id="Request1" type="checkbox" Value= "Paper Map, "tabindex="6" > Paper Map

<input ListFieldName="Request" name="Request2" id="Request2" type="checkbox" Value= "Digital Map (.pdf), "tabindex="6" > Digital Map (.pdf)

<input ListFieldName="Request" name="Request3" id="Request3" type="checkbox" Value= "Digital Map (Web Map), "tabindex="6" > `

Thank you!

saraa71a avatar Jan 07 '19 14:01 saraa71a