Select to view content in your preferred language

Nested Repeats in Power Automate Email

686
4
05-14-2024 11:28 AM
jzibbell_boise
Regular Contributor

I am struggling to figure out how to get the data I am collecting through nested repeats into a format that will not send 9 emails via Power Automate every time there is a submission. I tried initialize variable (string and array), but I can't get the parent repeat to match up with the child repeat. I either get blank fields for the parent or blank fields for the child. I was thinking I could probably create a hidden field in my survey to bring all of the data together but my head started to explode. Thanks for the help!

 

jzibbell_boise_0-1715711058564.png

 

0 Kudos
4 Replies
abureaux
MVP Frequent Contributor

You need to utilize the uniquerowid and parentrowid fields in your survey submission, as well as Apply to each and Condition from Power Automate.

This seems to be common enough that I should toss together a quick guide... which I think I will do today.

abureaux
MVP Frequent Contributor

Well, today was a lot busier than I was expecting. I put together a rough guide on handling repeats in Power Automate, but honestly my brain is numb now. Time for supper! I will read it over again tomorrow since I'm afraid I missed something (I had to restart several times due to interruptions).

@jzibbell_boiseIf this isn't actually related to your problem, just say so and we can have a look at your specific flow.

jzibbell_boise
Regular Contributor

@abureaux my mind is blown. But I started walking through it and didn't see these fields in my code, uniquerowid and parentrowid. I'm assuming it's globalid and parentglobalid? FYI - before I heard back from you my work around was to put the parent repeat values I wanted as hidden fields in the child repeat. So the users only had to do one data entry, but the data was available to me at the level I needed it without triggering 9 emails. I also attached the text if that's easier. 

{
"applyEdits": [
{
"id": null,
"adds": [
{
"attributes": {
"changeofStatus": null,
"changeOther": null,
"changeOtherDate": null,
"changeOtherComments": null,
"changeOtherDateFormat": null,
"promotionsAll": null,
"transfersAll": null,
"temps": null,
"specialtiesAll": null,
"specialtiesNames": null,
"globalid": "{AEBA5E48-BAA0-46FE-8AE9-DC7DCB1992B6}"
}
}
]
},
{
"id": null,
"adds": [
{
"attributes": {
"transferEffectiveDate": null,
"parentglobalid": "{AEBA5E48-BAA0-46FE-8AE9-DC7DCB1992B6}",
"globalid": "{802F82C3-3EE9-42C4-81DC-F5E4B9EEC00D}"
}
}
]
},
{
"id": null,
"adds": [
{
"attributes": {
"firstNameTransfer": null,
"lastNameTransfer": null,
"middleNameTransfer": null,
"fromRankTransfer": null,
"fromRankTransfer2": null,
"fromRankTransferOther": null,
"toRankTransfer": null,
"toRankTransfer2": null,
"toRankTransferOther": null,
"transferToAssignment": null,
"transferToAssignment2": null,
"transferToAssignmentOther": null,
"fromShiftTransfer": null,
"fromShiftTransfer2": null,
"lastDayTransfer": null,
"toShiftTransfer": null,
"toShiftTransfer2": null,
"transferReportDate": null,
"commentsTransfer": null,
"lastDayTransferFormat": null,
"transferReportDateFormat": null,
"transferEffectiveDateFormat": null,
"parentglobalid": "{802F82C3-3EE9-42C4-81DC-F5E4B9EEC00D}",
"globalid": "{7EDCCE8D-93B7-4AA9-8012-E07AC2D79F02}"
}
}
]
}
],
"response": [
{
"id": null,
"addResults": [
{
"objectId": null,
"uniqueId": null,
"globalId": "{AEBA5E48-BAA0-46FE-8AE9-DC7DCB1992B6}"
}
]
},
{
"id": null,
"addResults": [
{
"objectId": null,
"uniqueId": null,
"globalId": "{802F82C3-3EE9-42C4-81DC-F5E4B9EEC00D}"
}
]
},
{
"id": null,
"addResults": [
{
"objectId": null,
"uniqueId": null,
"globalId": "{7EDCCE8D-93B7-4AA9-8012-E07AC2D79F02}"
}
]
}
],
"feature": {
"attributes": {
"changeofStatus": null,
"changeOther": null,
"changeOtherDate": null,
"changeOtherComments": null,
"changeOtherDateFormat": null,
"promotionsAll": null,
"transfersAll": null,
"temps": null,
"specialtiesAll": null,
"specialtiesNames": null,
"globalid": "{AEBA5E48-BAA0-46FE-8AE9-DC7DCB1992B6}",
"objectid": null
},
"result": {
"globalId": "{AEBA5E48-BAA0-46FE-8AE9-DC7DCB1992B6}",
"objectId": null,
"uniqueId": null
},
"repeats": {
"Transfer": [
{
"attributes": {
"transferEffectiveDate": null,
"parentglobalid": "{AEBA5E48-BAA0-46FE-8AE9-DC7DCB1992B6}",
"globalid": "{802F82C3-3EE9-42C4-81DC-F5E4B9EEC00D}",
"objectid": null
},
"result": {
"globalId": "{802F82C3-3EE9-42C4-81DC-F5E4B9EEC00D}",
"objectId": null,
"uniqueId": null
},
"repeats": {
"personnelAffectedTransfer": [
{
"attributes": {
"firstNameTransfer": null,
"lastNameTransfer": null,
"middleNameTransfer": null,
"fromRankTransfer": null,
"fromRankTransfer2": null,
"fromRankTransferOther": null,
"toRankTransfer": null,
"toRankTransfer2": null,
"toRankTransferOther": null,
"transferToAssignment": null,
"transferToAssignment2": null,
"transferToAssignmentOther": null,
"fromShiftTransfer": null,
"fromShiftTransfer2": null,
"lastDayTransfer": null,
"toShiftTransfer": null,
"toShiftTransfer2": null,
"transferReportDate": null,
"commentsTransfer": null,
"lastDayTransferFormat": null,
"transferReportDateFormat": null,
"transferEffectiveDateFormat": null,
"parentglobalid": "{802F82C3-3EE9-42C4-81DC-F5E4B9EEC00D}",
"globalid": "{7EDCCE8D-93B7-4AA9-8012-E07AC2D79F02}",
"objectid": null
},
"result": {
"globalId": "{7EDCCE8D-93B7-4AA9-8012-E07AC2D79F02}",
"objectId": null,
"uniqueId": null
},
"attachments": null
}
]
},
"attachments": null
}
]
},
"attachments": null
}
}
0 Kudos
abureaux
MVP Frequent Contributor

"...my work around was to put the parent repeat values I wanted as hidden fields in the child repeat..."

This is definitely a viable solution, especially with small data sets.

In your case, yes, for whatever reason you will be working with globalid and parentglobalid. They appear to serve the same purpose as uniquerowid and parentrowid. I see no reason why the logic I used in my guide post shouldn't work with that JSON response.

Assuming that these variables are used during Edit and Resend actions(?) and the values I stated are for new submissions, you could easily add Initialize Variable steps, then use a Condition to test what type of survey submission you have, and then Set Variable for globalid/uniquerowid and parentglobalid/parentrowid as appropriate. This would allow you to have a single flow for all submission types.

0 Kudos