cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
McMonty
Resolver I
Resolver I

Multiple Choice data from Microsoft Forms

Hi,

I have a SharePoint list with data from a Microsoft Forms survey. One of the fields is a multiple choice field where the data looks like this:
["Option 1","Option 2","Option 3"]

 

I'm not sure if this is an array, but I'm trying to turn the above into the string below:

Option 1; Option 2; Option 3

 

Any idea how this could be done?

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @McMonty,

 

The output of the Choice type answer for MS Form will be string, so the only way to process the string to you want is some part of @Jay-Encodian's method 1.

 

You can add the replace function in the right Expression Bar:

Annotation 2019-12-02 170039.png

 

 

You can try this expression, the variables('Choice') is the output of your Choice answer:

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hey@v-litu-msft @McMonty 

To parse the string to an array use the JSON expression:

a.png

Expression: json(<formVariable>)

a.png

Super simple 🙂

HTH

Jay

View solution in original post

8 REPLIES 8
Jay-Encodian
Super User II
Super User II

Hey @McMonty 

The following solution works albeit it it way more complex than I'd like!

1.png

 1. Create an array of chars which need to be removed from the string: createArray('[',']','"')

1.png

 2. Add a variable to store the 'Initial value' I've manually set the value...

1.png

 3. Add a new variable to store the changing / new value

1.png

4. Add an 'Apply to each loop'

5. Set the 'Output from previous steps' to the array variable created in step #1

6. Add a 'Set Variable action', add the following expression: replace(variables('InitialValue'),item(),'')

1.png

 7. Add a 'Set Variable action' to copy the NewValue to the InitialValue variable... you can't self reference in the replace expression 😞

1.png8. Finally... Add a another 'Set Variable' action underneath the 'Apply to each' loop to perform the final replace expression: replace(variables('InitialValue'),',','; ')

1.png

 Your Flow config should look like this... a little convoluted but it works!:

1.png

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

 

Hey @McMonty 

So this was really bugging me yesterday... I thought there must be an easier way! and there is!

I forgot about the 'Join' action... much simpler:

a.png

 

a.png

 

A little bit simpler!

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

Hi, my only question is where in the previous solution do I add / replace this?

Hi @McMonty 

The second post totally replaces the the first post... they are both complete answers that do the same thing in a different way.

The second post is obviously a lot simpler...

All you really need is the 'Join' action passing in your Form data... that's it 🙂

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

 

Hi @McMonty,

 

The output of the Choice type answer for MS Form will be string, so the only way to process the string to you want is some part of @Jay-Encodian's method 1.

 

You can add the replace function in the right Expression Bar:

Annotation 2019-12-02 170039.png

 

 

You can try this expression, the variables('Choice') is the output of your Choice answer:

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hey@v-litu-msft @McMonty 

To parse the string to an array use the JSON expression:

a.png

Expression: json(<formVariable>)

a.png

Super simple 🙂

HTH

Jay

View solution in original post

McMonty
Resolver I
Resolver I

Hi all,

 

Big thanks to you both!

 

I created a variable containing the data from the multiple choice field and then used replace to get the string I wanted when creating the SharePoint item.

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

You learn something new everyday 🙂

You learn something new every day 🙂

 

DanielS19
Frequent Visitor

Hello Everone!

Thank you for solved !

Is it possible to skip lines for each string received from this solution?

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (27,182)