cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KF123
Regular Visitor

Conditional Paragraphs inside of Word Templates decided by Microsoft Forms

I am trying to include conditional paragraphs inside of a word template. The flow connects Microsoft Forms to Microsoft Word. I want specific paragraphs to appear inside of the word template based on the response to a Yes/No question in forms. For example "Is a Solicitor involved in this case?" If Yes, the paragraph containing the Solicitors information is included inside the template. If No, then the paragraph is removed.

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Microsoft
Microsoft

Hi @KF123 

When you create your word template for each of the paragraphs, leave them empty like so:

 

DamoBird365_0-1615466430597.png

Then in your flow you can leave the paragraph sections blank based on your scenario:

 

DamoBird365_1-1615466510055.png

 Your word doc looks like follows:

DamoBird365_2-1615466623109.png

 

 

You could construct each field/paragraph with an expression similar to the following:

 

if(equals(outputs('Get_response_details')?['body/r02704eb9a83b4766b887c4a715634062'],'Yes'),'Lots of Text','')

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien

View solution in original post

7 REPLIES 7
DamoBird365
Microsoft
Microsoft

Hi @KF123 

When you create your word template for each of the paragraphs, leave them empty like so:

 

DamoBird365_0-1615466430597.png

Then in your flow you can leave the paragraph sections blank based on your scenario:

 

DamoBird365_1-1615466510055.png

 Your word doc looks like follows:

DamoBird365_2-1615466623109.png

 

 

You could construct each field/paragraph with an expression similar to the following:

 

if(equals(outputs('Get_response_details')?['body/r02704eb9a83b4766b887c4a715634062'],'Yes'),'Lots of Text','')

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien

Hi @DamoBird365 - Thank you so much; it looks logically sound however I am having an issue with an the final result.

 

The expression is valid and is being excepted by Power Automate however my output is blank despite the Yes answer to the question within the form. I am closer to achieving what is required than before so thank you for that.

 

Any idea what I might be missing?

Hi @KF123 ,

 

Can you share a screenshot of the action that creates your output?  Take a close look at the history input/output, it could be a typo or maybe the value Yes is not as you might expect.  It might also be case sensitive.  So look for the yes result in the history and check your logic.

 

Damien

Reading the history of both a 'Yes' and a 'No' test shows that in the Yes version the text is appearing as desired:

 

In the 'Yes' instance:

KF123_0-1615476581873.png

In the 'No' instance:

KF123_1-1615476650606.png

However the template that is created in either instance of Yes or No appears blank:

KF123_2-1615478688626.png

 

My Expression is as follows:

 

if(equals(outputs('Get_response_details')?['body/r4c982d6d6dfe476690ea36cd2bc5c56d'],'Yes'),'Thank you for providing the relevant paperwork we need to see from you in order to verify your identity and address so that we can comply with UK money laundering procedures.','')

 

 

This might sound silly @KF123 but have you created a new file and apologies if I have misunderstood?  When you populate the template, you need to save the output to a file per my screenshot.

KF123
Regular Visitor

Yes the new file creation is the end of the flow which works fine - the template is created and saved in a SharePoint. The paragraph variable within the document remains blank even with the 'Yes' option being selected which the expression should then populate as I understand.

 

Thanks

Hi @KF123 

 

From your screenshot, it looks like you have confirmed your yes/no if expression is working.

 

So your solution looks like:

DamoBird365_1-1615481701306.png

And the new file name (in my case test.docx) shows nothing in the word doc - i.e. you're not looking at the original template?

 

What happens if you replace the expression in one of the paragraphs with just a string.  

 

DamoBird365_2-1615481793960.png

 

Presumably as your history shows text for the yes / no scenario I think it looks like the link to your template isn't working.  You might want to try re-adding the template file to the "populate a word template action" - could the file have changed resulting in the field names changing?

 

Damien

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,115)