Easily address escaped characters in Forms Response

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?

Microsoft Form Multiple Answers Selected

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.

Cloud Flow, how to correct escaped characters in JSON returned by Microsoft Forms

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

Perfectly formatted JSON using json() expression in Power Automate

Option 2

Formatted output with return lines using select action

Option 3

Formatted list using select action

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.

Share