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?
Solved! Go to Solution.
Hi @KF123
When you create your word template for each of the paragraphs, leave them empty like so:
Then in your flow you can leave the paragraph sections blank based on your scenario:
Your word doc looks like follows:
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 @KF123
When you create your word template for each of the paragraphs, leave them empty like so:
Then in your flow you can leave the paragraph sections blank based on your scenario:
Your word doc looks like follows:
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:
In the 'No' instance:
However the template that is created in either instance of Yes or No appears blank:
My Expression is as follows:
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.
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:
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.
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
User | Count |
---|---|
92 | |
45 | |
20 | |
19 | |
15 |
User | Count |
---|---|
137 | |
54 | |
43 | |
42 | |
30 |