I am currently working on a flow that takes in responses from a Microsoft Form. In this flow, I am trying to convert certain responses in the questions of the form to a numeric value and then calculate the value of all the responses.
For example:
What is your favorite Nintendo character?
a. Mario
b. Link
c. Kirby
If they answered Mario, the score for that question would be 7.5. If they answered Link, it would be 5.5. If they answered Kirby, it would be 3.5.
After the steps where I get the form responses, I have an "Initialize variable TotalValue" set to:
Name: TotalValue
Type: Integer
Value: 0
Then I have an "Apply to each" action with an output of "triggerBody()?['body']"
In the Apply to each, I have a Switch action titled "Nintendo Characters" with "On" set to "items('Apply_to_each')['What is your favorite Nintendo character']"
There are 3 cases in the Switch: Mario, Link, and Kirby. Each one has a Compose action with these inputs:
Mario
Equals: Mario
Compose: Inputs:
add(variables('TotalValue'), 7.5)
Link
Equals: Link
Compose: Inputs:
add(variables('TotalValue'), 5.5)
Kirby
Equals: Kirby
Compose: Inputs:
add(variables('TotalValue'), 3.5)
There are 3 other Switch actions that are created similarly (different content but same idea with the Compose actions inside the Cases) and all reside inside the "Apply to each" action.
When I fill out the form, it fails, and I can see this when I look at the Run details:
Error Details:
The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['body']' is of type 'Null'. The result must be a valid array.
I have tried having the "Apply to each" action have an output of "triggerOutputs()?['body']" however the flow still fails and I get this:
Error Details:
The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body']' is of type 'Object'. The result must be a valid array.
Any help would be greatly appreciated.