Using Power Automate/ Survey123 connector with nested repeats

03-02-2022 01:36 PM
New Contributor III

Hello. I am really struggling with trying to use the Survery123 connector in Power Automate. My survey is quite complex with nested repeats. There is a repeat called lineData, and there can be any number of lines, and there is a repeat called issues which is nested so each line can have any number of issues. I want to use the dynamic data from inside those repeats to email out a report, but the dynamic data windows are too narrow to differentiate between the values. I can't expand the box or get the full info of the value. There are MANY of these, so it's impossible to keep them straight. I have therefore tried to use the expressions to access the dynamic data, but the syntax is not easy to figure out. 


I decided to make a string to contain all of the issue numbers (one of the fields in the issues table), and to try to create that string, I started with a string variable and am using the Append to String function. However, to try to access this, I have only had luck putting it inside a nested Apply to Each where I loop through the lineData and then through the issue data. However, this is causing the 2 values that should be written to be duplicated into 4 values. 

In my test case, there were 2 lines with one issue on each line. The first one's issue number was a string "tired" and the second one had an issue on structure number 6. The nested loop should then have updated the structure variable to be structure=issue, 6. Instead, it is giving structure-issue, 6, issue, 6. 

Does anyone have any idea what is going wrong? From a programming point of view, I would guess that it is looping through all lines and then all issues and not associating the issues to the specific lines. However, I'm not sure how to correct this.

I'm sharing my nested loop:

the first feature repeats is triggerOutputs()?['body/feature/repeats/lineData']

the one inside Update NE Lines is items('NE_Circuit_IDs')?['attributes/NEcircuitID']

the input to the NEIssueLoop is items('NE_Circuit_IDs')?['repeats/issue']

and the one inside Update Structures is items('NEIssueLoop')?['attributes/strName']

I did try to take the NEissueLoop out of the NE Circuit IDs loop, but then it couldn't find the strName attribute. I tried with triggerOutputs()?['body/feature/repeats/issue'] as the input, but it didn't work. Does anyone have any advice? This syntax is really hard for me to figure out.



0 Kudos
1 Reply
New Contributor II

Hi Stacy,

I recommend running the flow without any process, then looking at the flow run history and it will allow you to see the entire payload and structure of the survey data. 

You can copy this out of Power Automate and into a text editor or MS Word and it will be easier to understand the structure and how you need to arrange your processing.

0 Kudos