Select to view content in your preferred language

Power Automate email formatting with empty questions/answers

2822
6
Jump to solution
06-22-2021 03:00 PM
AndrewPriest
Emerging Contributor

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

6 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
Emerging Contributor

perfect! thank you, Ismael

0 Kudos
JeffLegato1
Frequent Contributor

@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
Frequent Contributor

@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
Sietse_de_Haan
Regular Contributor

Thank you for sharing your expression. Just what I needed! 

Sietse de Haan
https://www.linkedin.com/in/sietse-h-de-haan/
0 Kudos
SayedWali
Regular Contributor

@JeffLegato1 

However, I am passing dates for a column that is in a repeat table. The field sometimes needs to be passed as null and sometimes will be filled with a date. Among my searches, your statement helped a lot. Thanks anyway. Here it is:

 

if(equals(items('Apply_to_each')?['attributes/Date_Completion'],null), null, convertTimeZone(addseconds('1970-1-1', Div(items('Apply_to_each')?['attributes/Date_Completion'],1000)),'UTC','Afghanistan Standard Time','d'))