Search code examples
power-automatemicrosoft-forms

How do I work with Microsoft Forms' arrays that are formatted as strings in the trigger body?


I have a MS form where I am asking for multiple attachments. In the forms response body from the trigger, the attachments array is formatted as a string. I want it to be an array so I can loop through it and parse each object and move on. This is much more complex than it should be. How do I get this to be an array in power automate so I can loop through it? I cannot initialize an array variable with this value because it is a string.

Here is what the response data looks like (see the highlighted field's value is a string): enter image description here

I have tried to cast is as an array with the "array()" function and that does not work. This is what happens when I do that:casting to an array

I also tried to remove the quotes from the first and last characters of the string to no avail. Any help is very appreciated!


Solution

  • Use the json() expression, not array().

    I'd give you a better answer but it's not that simple given the question is a little ambiguous with how your flow is structured, i.e. I can't see it all.

    Either way, use json(), that will do it for you.