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:
Here is my flow:
Note that the compose action has no real puposes it is just to visualise the output for the question.
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?
Many thanks in advance,
Solved! Go to Solution.
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.
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
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?
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.
Can you please show what your expression was to correct this?
Forms multiple choice --> Sharepoint List look no further: John Liu has a better solution:
https://www.youtube.com/watch?v=dNZydb1QH4o&ab_channel=JohnLiu
Just create an expression and do this
json(outputs('Get_response_details')?['body/r555abb6d4c254b339a5731eda30d9c3e'])
User | Count |
---|---|
16 | |
16 | |
14 | |
9 | |
8 |
User | Count |
---|---|
31 | |
28 | |
25 | |
23 | |
13 |