Select to view content in your preferred language

How to selectively add Power Automate arrays (from Survey123 repeats) to an email

301
1
12-19-2024 09:41 AM
WilderNiss1
Occasional Contributor

I am trying to design an auto-generated email from Survey123 responses. I have set up a Power Automate for this purpose. My survey includes multiple repeats (but none are nested). Each repeat has a "relevant" question, so that if surveyors answer the question with "yes", the repeat will open for them to fill out. 

I want to include the information from these repeats into my auto-generated email. I have set up arrays to collect data from each of these repeats. Then I set up an HTML table for each of these arrays, that can easily be added to the email body. There are a total of 5 arrays (or 5 repeats) within my flow/survey.

Now the tricky part. I would like to only include the arrays in the email when they are relevant, or people answered yes to that aforementioned relevant question in the survey. 

I want to structure the email body with a pre-set title above the inserted tables (tables themselves will be dynamic of course). Does anyone have any clever ideas on how to do this with conditions or something? Trying to minimize the amount of complications. 

Note: each repeat is independent of the other, so just because one isn't relevant, that doesn't remove any others. So could be an email with all 5 arrays, or 1, 2, and 4, or 1, 4, and 5, or 3, 4, 5... you get the idea. 

Thanks!

0 Kudos
1 Reply
abureaux
MVP Frequent Contributor

Expressions can help here.

For the title, something like this may work. Add a Compose action, go to the Expression tab, and try something similar to:

if(equals(<your s123 question>,'yes'),concat('Title for first table',decodeUriComponent('%0A')),'')
The decodeUriComponent('%0A') should add a carriage return. Adding carriage returns to the expressions ensures you don't end up with a bunch of random empty lines.
 

Honestly, creating a Feature Report and attaching that would likely be the easiest method, and would allow for a high level of customization.

Also, I'm heading out right now so can't set up any real examples. But give that a shot and let me know how it goes.

0 Kudos