I was asked to create a Stormwater Inspection form using Survey 123 and have run into an issue. I am basically trying to create email notification each time new repeat data is added to the form. Just to give a rundown, I have the form set up with general information fields such as fields like contractor name, phone number, email and etc. And then I have a repeat section in which a new inspection will be created weekly until a project site is complete. What I would like to do is create an email in powerautomate that has that general information, but also the latest repeat data. Thus far, I have created the trigger in power automate, then a condition, but when I add a field from the repeat data to the body section, it asks me to add another action called "Apply to each" and it is that section where progress stalls. Would anyone have experience in doing such a thing? If I need to, I can add my xml file. Thanks in advance.
Solved! Go to Solution.
Hi. The behavior you describe is expected. The Survey123 webhook payload models records within a repeat as an array. This is the case because in a repeat you may have one or more records. In Microsoft Power Automate, the standard behavior to handle an array is t add an 'Apply to each' block. Using the Initialize variable and append to variable modules will let you aggregate information from your array.
Overall, your workflow could look as follows:
Note that I added an Initialize Variable before the Apply to each. Within the Apply to each bock you can use the Append to variable module to aggregate data from your repeat and ultimately reference that variable within your email to bring all the aggregated repeat data into your email content.
Hi. The behavior you describe is expected. The Survey123 webhook payload models records within a repeat as an array. This is the case because in a repeat you may have one or more records. In Microsoft Power Automate, the standard behavior to handle an array is t add an 'Apply to each' block. Using the Initialize variable and append to variable modules will let you aggregate information from your array.
Overall, your workflow could look as follows:
Note that I added an Initialize Variable before the Apply to each. Within the Apply to each bock you can use the Append to variable module to aggregate data from your repeat and ultimately reference that variable within your email to bring all the aggregated repeat data into your email content.
Thank you, Ismael. So I was able to create a flow, yet there items in the repeat section did not show in my "test" email. The only items that showed in the email were two brackets. I assume there should be some sort of data within those brackets. You mentioned appending the output of the "RSF" variable, but I am unsure what to append that data too. Please see workflow below.
Also below are peeks into my code.
Initialize Variable
Compose
It appears to me that the RSF out is included in a paragraph, but yet it does not show up in the email after I submit a survey.
does anyone have further examples of this? Tested it out and so far, not working. Thanks.
I have the entire process working and has been working for over a year. Cannot express how efficient and effective this setup is. Our stormwater team loves it. If you'd like to ask any questions, contact me at jsimpson@salemva.gov.
Thanks so much! will inbox you- much appreciated!!