Power Automate email formatting with empty questions/answers

591
4
Jump to solution
06-22-2021 03:00 PM
AndrewPriest
New Contributor II

hi. an email is triggered by a Survey123 submission. the survey has many questions that will not have answers, but I'm using dynamic expressions in the email to list all of the questions/answers in the survey. rather than listing a blank space for the unanswered questions is there a workflow to populate "NA" or "Empty"? can the payload be configured to update the dynamic content in Power Automate accordingly? Example:

Project Number: PRJ-000119
Activity in a Building: No
Building Floor(s): is "NA" or something rather than blank a dynamic option for these non-answers?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

I think the coalesce() function in Power Automate will do the trick for you.  This function can take a value from dynamic content and a fixed string (such as "NA"). If your value from dynamic content is empty, it will return your fixed string.

For example if my Survey123 question called dept is empty, I will get back NA: coalesce(triggerOutputs()?['body/feature/attributes/dept'],'NA')

Coalesce.gif

 

View solution in original post

4 Replies
IsmaelChivite
Esri Notable Contributor

I think the coalesce() function in Power Automate will do the trick for you.  This function can take a value from dynamic content and a fixed string (such as "NA"). If your value from dynamic content is empty, it will return your fixed string.

For example if my Survey123 question called dept is empty, I will get back NA: coalesce(triggerOutputs()?['body/feature/attributes/dept'],'NA')

Coalesce.gif

 

AndrewPriest
New Contributor II

perfect! thank you, Ismael

0 Kudos
JeffLegato1
New Contributor III

@IsmaelChivite Thanks for this! What if I have a date field that I need to test if it's null then return some text or if not null then return the date but format it appropriately?  I have been using this successfully to format the date:

convertTimeZone(addSeconds('1970-01-01',div(triggerBody()?['feature']?['attributes']?['InspDate'],1000)),'UTC','Pacific Standard Time','D')

Any help would be appreciated. 

0 Kudos
JeffLegato1
New Contributor III

@IsmaelChivite  Never mind I got it working!  I ended up using an if statement.

if(equals(triggerOutputs()?['body/feature/attributes/InspDate'],null), 'No inspection date recorded', convertTimeZone(addSeconds('1970-01-01',div(triggerOutputs()?['body/feature/attributes/InspDate'],1000)),'UTC','Pacific Standard Time','D'))

 

0 Kudos