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?
Solved! Go to Solution.
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')
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')
perfect! thank you, Ismael
@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.
@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'))
Thank you for sharing your expression. Just what I needed!
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'))