Do you want to easily address escaped characters from the multiple answers string returned by Microsoft Forms in Power Automate? The reponse looks like an Array but the double quotes are escaped.
When you select the dynamic answer from a question and run it through an apply to each action you get an error:
The result of the evaluation of ‘foreach’ expression ‘@outputs(‘Get_response_details’)?[‘body/rcc56958db4dd4ed5add1fdbe90758a2b’]’ is of type ‘String’. The result must be a valid array.
Should you use the replace expression in order to retrieve these values? The answer is NO
Below we have a sample multiple answer question on Microsoft Forms. Being so indecisive, 4 choices have been made. The cloud flow output returned by the “Get Response Details” action includes escaped double quotes \”. The result looks like follows:
“rcc56958db4dd4ed5add1fdbe90758a2b”: “[\”Green\”,\”Blue\”,\”Orange\”,\”Purple\”]”
How can we work with that? There are many answers suggesting that the replace expression is used. Did you know about the JSON() expression?
Sample Cloud Flow
Below a sample cloud flow that will return three outputs.
Option 1 by using the JSON() expression, the escaped double quotes will be cleaned up. A clean array is returned to use in an apply to each.
Option 2 using the “ReturnLine” compose action with a return line (i.e. insert your cursor and hit return on your keyboard) you can join the array and insert a return between all values. Perfectly formatted for an email or inserting into a field in a SharePoint List or Excel.
Option 3 a new comma seperate list. The alternative to the values returned on seperate lines.
Results from the Flow
For each of the options above, when the cloud flow is run, the following results are returned. Ready to use elsewhere in the flow.
Option 1
Option 2
Option 3
Have you used the json expression before? If you would like to see a use case for Microsoft Forms, convert the form response to a Word Document with dynamic content and then into PDF, click here.
Hello,
I can’t make this to work for email. I probably need step by step. I have three questions all with multiple choice answers and I’d like to email the response in the “Nicely Returned List”.
What is or isn’t working? What have you managed to output?
HI Damobird365, I used your tutorial to construct flow to word template which worked a charm. I then went about looking and trying numerous ways to remove characters from multi-option field selections. After rewriting the flow probably 20 times now with all the different methods I saw this one, so I decided to set up a test flow following your procedure here, just to see if it works. Lo and behold, it does the same as all the other methods I have tried (you can see my desperation here: https://powerusers.microsoft.com/t5/Building-Flows/Query-regarding-Apply-to-each-quot-loop-quot-to-remove-unwanted/td-p/1823732), so I’m starting to think it has maybe something to do with the content type column definition in SharePoint, where due to sentence character length, I am forced to define Multiple lines instead of single line column (I don’t use choice column since the choices are lengthy sentences and ultimately the data is populating a word template so SharePoint is column storage is not that important). Every example out there seems to be a simple selection option, but mine is much longer sentences to select.
Hi DamoBird,
I recently used your guide to create a PDF from a Form without Premium actions. It works well but there are a few multiple choice questions which I would like in the “Nicely Returned List”. Are you able to help with this?
Hi there Imran. Have you tried using json and split? I’ve a new video which might be of help if you watch towards the end I created a number list. Otherwise let me know what you’ve tried and what you’re stuck with.
https://youtu.be/Bx0MTzyG4v8
Thanks DamoBird,
This worked well for the PDF form that I have created.
However, I have some multiple choice questions in my form where the submitter will select the name of the project lead.
For example:
Imran Mauthoor
James Bond
Harry Potter
I will need to send an email to the selected individuals ( all of whom will have the email domain “@whitfieldconstructionservices.co.uk”
So the output I believe I will need will be:
Imran.Mauthoor@whitfieldconstructionservices.co.uk; James.Bond@whitfieldconstructionservices.co.uk; Harry.Potter@whitfieldconstructionservices.co.uk
Any idea for the best way to go about this?
Many thanks!
Damon you are a legend. Your videos on youtube are super helpful and this short guide does exactly what I need it to do.
Thank you