Power Automate Email.

1687
7
Jump to solution
01-26-2021 12:24 PM
JasonSimpson
New Contributor III

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. 

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

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:

Automate_004.png

 

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.

 

 

View solution in original post

7 Replies
IsmaelChivite
Esri Notable Contributor

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:

Automate_004.png

 

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.

 

 

JasonSimpson
New Contributor III

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. 

 

JasonSimpson_0-1611755844963.png

JasonSimpson_1-1611755890055.png

 

 

0 Kudos
JasonSimpson
New Contributor III

Also below are peeks into my code. 

 

Initialize Variable

JasonSimpson_0-1611764196225.png

 

Compose

JasonSimpson_1-1611764272762.png

Email

JasonSimpson_2-1611764334715.png

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.

 

 

 

 

0 Kudos
survey123_solutions
New Contributor III

does anyone have further examples of this?  Tested it out and so far, not working.  Thanks.

0 Kudos
JasonSimpson
New Contributor III

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

0 Kudos
survey123_solutions
New Contributor III

Thanks so much! will inbox you- much appreciated!!

0 Kudos
VirginieLe_Gal
New Contributor III

Hello everyone,

I don't understand where the feature repeat is shown in the power automate script. In the images, I never see the feature repeat. Should it be in place of the current item in the compose action?


Thanks for your help

0 Kudos