Manually adding a field in the email body using Microsoft Flow from Survey 123

2668
5
Jump to solution
11-13-2020 07:43 AM
LindaSlattery
Occasional Contributor

I am creating a webhook using Microsoft Flow (Power Automate) from Survey 123 responses. I am trying to get all of the fields to appear in the body of the email, but only the text fields show up in the dynamic content. So I have to manually add the integer and date fields. I found a page from Ismael Chivite (https://community.esri.com/t5/arcgis-survey123-blog/automating-workflows-with-survey123-and-microsof...) that says you can add hidden content using the following syntax: 

?['feature']?['attributes']?['yourhiddenquestioname']

I substituted one of the integer field names into the 'yourhiddenquestionname' part, ran a test and it did not work. I assume I have to substitute something into the 'feature' and 'attributes', but I am not sure what. Can anyone help with this and provide and example that I can follow?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
LindaSlattery
Occasional Contributor

James, I accidentally figured it out by copying everything in the body and pasting it into notepad. By doing this, it shows the exact syntax that the dynamic variables used. For your reference, and everyone elses, it is:

@{triggerOutputs()?['body/feature/attributes/FIELDNAME']}

Replace FIELDNAME with the field name you want added. I made the changes in Notepad and then copied and pasted into the body in Power Automate/Flow.

Thanks for your help! You steered me in the right direction 🙂

Linda 

View solution in original post

5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi,

This is a question concerning MS Power Automate syntax, so we can provide limited help.  Doing a little bit of testing, it appears that the Power Automate preferred syntax for accessing webhook outputs may have been updated.  The easiest way to see this is to create a formula that uses one of the inputs (as @IsmaelChivite did in the blog post).  In his blog post, he had:

addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['mydate'],1000) , 'yyyy-MM-dd')

When I attempt the same calculation in Power Automate, I am now seeing:

addSeconds('1970-01-01', div(triggerOutputs()?['body/feature/attributes/date_survey'], 1000), 'yyyy-MM-dd')
 
Note the change from an array-like access specification to a directory/tree-like access specification; this appears to be caused by the use of triggerOutputs instead of triggerBody.  This article does a reasonable job of explaining the triggerOutputs/triggerBody difference in the formulas.
0 Kudos
LindaSlattery
Occasional Contributor

Thanks, James, but I am still not understanding what I need to do to manually add a field. Which expression do I use? I'm sorry for not understanding. This is my first attempt at using webhooks.

Thanks again.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

I would try the triggerOuputs method and try by bringing another field into an expression/calculatoin to get the syntax correct.  An easy one to use for text would be concat() (which joins text); if need be you could use an empty string ('') as what it would join with.

0 Kudos
LindaSlattery
Occasional Contributor

James, I accidentally figured it out by copying everything in the body and pasting it into notepad. By doing this, it shows the exact syntax that the dynamic variables used. For your reference, and everyone elses, it is:

@{triggerOutputs()?['body/feature/attributes/FIELDNAME']}

Replace FIELDNAME with the field name you want added. I made the changes in Notepad and then copied and pasted into the body in Power Automate/Flow.

Thanks for your help! You steered me in the right direction 🙂

Linda 

DickieRigdon
New Contributor III

Thanks Linda for posting your solution!  Exactly what I was looking for.  Works great!

0 Kudos