cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stardustWB
Frequent Visitor

Append Forms responses with a specific answer to an email

My problem is following: there's a Forms form meant to be filled out during a safety walk. You choose the room/part of the company property (such as customer service desk, or front- or backyard) from a drop down menu. Then there are choice questions on observations or aspects such as Cleanliness, Lighting, etc. and you choose whether the aspect is OK or in need of fixing. You can also write down details in case there's something to fix. The Form responses are saved to a list on Sharepoint.

 

My question is: how could I build a flow that picks only the questions answered "Needs to be fixed", the choice answer itself and the related details? So that these could then be appended to an email to be sent to the office manager.

 

This is what I would need the email to look like:

 

Employee X has filled out form Y. The following observations were made:

 

Room: Customer service desk

Cleanliness: Needs to be fixed

Details on Cleanliness: There's trash on the floor

Lighting: Needs to be fixed 

Details on lighting: A light bulb has gone out

etc.

 

I've been trying things from getting the Forms responses directly to getting them from the list, but find it difficult to even understand how to approach the problem.

1 ACCEPTED SOLUTION

Accepted Solutions
v-LilyW-msft
Community Support
Community Support

Hi @stardustWB 

Do you want to display the question and its details in the email only when the question's answer is 'Needs to be fixed' option?

I set up a flow, you can refer to the screenshots below to see if it helps.

This is my test Form

vLilyWmsft_6-1637641234409.png

Flow in details

vLilyWmsft_1-1637640913121.png

Add 4 Compose actions and change the names of the actions to the corresponding questions in order to distinguish.

vLilyWmsft_3-1637641093039.png

vLilyWmsft_2-1637640974194.png

Expression1:

if(equals(outputs('Cleanliness'),'Needs to be fixed'),concat('Cleanliness:',outputs('Cleanliness'),'</br>','Details on Cleanliness:',outputs('Details_on_Cleanliness'),'</br>'),null)

Expression2:

if(equals(outputs('Lighting'),'Needs to be fixed'),concat('Lighting:',outputs('Lighting'),'</br>','Details on lighting:',outputs('Details_on_lighting'),'</br>'),null)

vLilyWmsft_4-1637641144655.png

vLilyWmsft_5-1637641195994.png

Save and test the flow.

When a new Form is submitted like below.

 

vLilyWmsft_0-1637640660823.png

The email will be sent like this.

vLilyWmsft_7-1637641382726.png

Hope the content above may help you.

Best Regards

View solution in original post

7 REPLIES 7
barret
Responsive Resident
Responsive Resident

What you will probably need to do is create a flow that triggers whenever a Forms form has been submitted. The trigger will be "When a new response is submitted". The trigger returns a list of responses that have not been processed previously. You'll then need to iterate through the list of responses using an "Apply to each" action. For each response, you then call the "Get response details" action to get the actual answers from the response. At that point, then you can look at the response to get the answers to the questions. Then you can examine the answers to the questions and determine which ones require that you take action on them. Something like this:

 

barret_0-1637347331388.png

 

v-LilyW-msft
Community Support
Community Support

Hi @stardustWB 

Do you want to display the question and its details in the email only when the question's answer is 'Needs to be fixed' option?

I set up a flow, you can refer to the screenshots below to see if it helps.

This is my test Form

vLilyWmsft_6-1637641234409.png

Flow in details

vLilyWmsft_1-1637640913121.png

Add 4 Compose actions and change the names of the actions to the corresponding questions in order to distinguish.

vLilyWmsft_3-1637641093039.png

vLilyWmsft_2-1637640974194.png

Expression1:

if(equals(outputs('Cleanliness'),'Needs to be fixed'),concat('Cleanliness:',outputs('Cleanliness'),'</br>','Details on Cleanliness:',outputs('Details_on_Cleanliness'),'</br>'),null)

Expression2:

if(equals(outputs('Lighting'),'Needs to be fixed'),concat('Lighting:',outputs('Lighting'),'</br>','Details on lighting:',outputs('Details_on_lighting'),'</br>'),null)

vLilyWmsft_4-1637641144655.png

vLilyWmsft_5-1637641195994.png

Save and test the flow.

When a new Form is submitted like below.

 

vLilyWmsft_0-1637640660823.png

The email will be sent like this.

vLilyWmsft_7-1637641382726.png

Hope the content above may help you.

Best Regards

Hi, thank you for your answer, this looks like what I need, and I'm trying it now. But can you clarify a bit: when writing the expressions, are the names (like Cleanliness) the names you give the Compose parts or the names of the dynamic content? Also, are the underscores required in the tail ends of the expressions (for example: Details_on_lighting)?

Hi @stardustWB 

The marked part is the name of Compose.

vLilyWmsft_1-1637656506940.png

If there is a space in the Compose name, it will be replace with '_' when use the outputs of the Compose.

Best Regards. 

Okay, the email displays all the answers, even those that aren't "Needs to be fixed". And it doesn't show the questions unless I add them directly to the Send email part. Wonder what I'm doing wrong here...

 

Can it be because I'm not using the Forms parts (When a new response is submitted and Get response details) but rather getting the responses from a Sharepoint list? (As there is already another flow that gets the responses and adds them to the list.) I'm doing this a recurring flow that once a day checks if there are new items in the list and if there are, sends the email.

barret
Responsive Resident
Responsive Resident

It would depend on how your SharePoint list is structured, but the concept should be the same. You examine each record in the list and the responses in that record and if they match your "Needs to be fixed" requirement, the compose action(s) will add it to the email output. If the questions themselves aren't stored in the SharePoint list, you would need to include them manually in your email template.

Just realized I had made a mistake when choosing the Outputs compose part in sending the email. Now it works like it should. Thank you!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (3,841)