cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gaetan
Frequent Visitor

Convert From multireply string into a valid array

Hello,

 

I getting headach converting a string into a array with Flow in order to iterate for each items.

 

I trying trigger a MS Flow for when a MS Form is submited. The Form contains a multiple options question. My issue is I can't found a way to itterate for each option selected.

 

Here is the question where I selecte Options and 3:

 

2017-07-21_11h13_26.png

Here is my flow:

Note that the compose action has no real puposes it is just to visualise the output for the question. 

 

2017-07-21_11h32_37.png

 

This is generating an error

 

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@@createArray(@outputs('Compose'))' is of type 'String'. The result must be a valid array.

 

The output of the question reply is a string like ["Option 1","Option 3"]. How can I convert this into a valid array?


2017-07-21_11h43_45.png

 

 Many thanks in advance,

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Gaetan
Frequent Visitor

 

I was finally able to have this work. In the the Apply to each output from previous steps i'm converting the string array from Form reply into a JSON. This is generating a valid array that the Apply to each will iterate through.

 

 

Sans titre.png

View solution in original post

5 REPLIES 5
v-micsh-msft
Community Support
Community Support

Hi @Gaetan,

 

The output of the first Compose is already an Array.

Please take a try to add the compose Output directly without the formula, see if it would work for the Apply to each.

 

Besides, if you would like to have the array elements into one string, then we need to use Join in another Compose, the formula should be:

"@join(outputs('Compose'),',')"

Regards,

Michael

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

Hello @v-micsh-msft,

 

Thanks for your feedback.

 

I tryiedto passthe compose output directly to the Foreachbut it fails:

 

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@outputs('Compose')' is of type 'String'. The result must be a valid array.

 

Seems like it is concideredas a string and not array.

 

What do you think?

 

2017-07-24_13h50_49.png

2017-07-24_13h47_30.png

 

 

 

Gaetan
Frequent Visitor

 

I was finally able to have this work. In the the Apply to each output from previous steps i'm converting the string array from Form reply into a JSON. This is generating a valid array that the Apply to each will iterate through.

 

 

Sans titre.png

View solution in original post

Can you please show what your expression was to correct this?

danishpowerapps
Advocate I
Advocate I

Forms multiple choice --> Sharepoint List look no further: John Liu has a better solution:
https://www.youtube.com/watch?v=dNZydb1QH4o&ab_channel=JohnLiu

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,053)