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

Populate a microsoft word template based on Form responses and conditional logic

Hi
I'm looking to create a document based on a Word template using responses from a Form. I would like to include conditional logic so that if a user selects 'A', then paragraph 1 is retained within the document and paragraph 2 is removed. If the user selects 'B' then paragraph 2 is retained and 1 is removed. I have the template, Form and document being updated on the responses but would appreciate guidance on building the conditional logic based on the Form response.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @JayH 

 

If you've already got your word template, I would create two compose actions, one for each paragraph (and just paste in the text) and then use an if expression in you word template action (albeit I have done this within a compose for the example below)

 

DamoBird365_0-1615991184688.png

Your if expression would be 
if(equals(triggerBody()['formanswer'],'A'),'outputs('Paragraph1'),outputs('Paragraph2'))
 
A good word template demo is here if you don't already have that in place.  You would only need one content control for this solution.
 

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

16 REPLIES 16

Hi @JayH 

 

If you've already got your word template, I would create two compose actions, one for each paragraph (and just paste in the text) and then use an if expression in you word template action (albeit I have done this within a compose for the example below)

 

DamoBird365_0-1615991184688.png

Your if expression would be 
if(equals(triggerBody()['formanswer'],'A'),'outputs('Paragraph1'),outputs('Paragraph2'))
 
A good word template demo is here if you don't already have that in place.  You would only need one content control for this solution.
 

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


JayH
Frequent Visitor

Thanks 

I seem to get an Error! Missing test condition  in the word document when its generated. 

im using the flow below with the if statement in word. 

 

 

Hey @JayH 

 

You'll need to share more details with me, the error, maybe the action where it occurs?

 

Thanks

 

Damien

JayH
Frequent Visitor

Hey - im capturing details in a form to generate a document (name, invoice number, and a random field where the user selects A or B).  if the input is A then paragraph 1 should be presented and if not then paragraph 2 in the document. 

The document seems to be generating ok with the name, invoice number populated based on the form input but the if statement doesnt appear to be working, instead giving me the error (the error appears on the word document in place of the if statement). 

i've created two compose actions just before the populate a word template action and have the if statement in the word template. 

does that help?

Hi @JayH 

 

Sounds like you've not used the expression builder, so it's literally just passing the string to the word doc.  You need to make sure that when creating an equivalent expression you and not in the dynamic content tab but the expression tab.  You will be able to see in the history of the run how the expression is being evaluated - if at all - as it sounds like a string right now.

 

Damien

Hi @JayH 

 

How are you getting on?

 

Damien

Hi Damien,

I am trying to do a similar thing. the link to the template demo doesn't exist any more.  I am new to microsoft 365 could you give me a bit more information on how to set this up.

 Thanks

 

Hi @liamduff88 ,

 

I am working on a video for this concept as I have had a few requests of late.  The demo will show how to use a Microsoft Form to dynamically populate sections of a word file using a Microsoft list for the text of each section.  Each section is optional based on a yes/no answer on the form.  I will demo this with both a single text control and via a repeating control.  Each section will also be able to have a running section number.

 

Hopefully that will capture most of your requirements.  I will post the link to the video here once it's up.

 

Damien

Thanks Damien,

I look forward to your video. Would you be able to add the logic on how to send one of two emails depending on the answer to a form question?

Thanks.

Liam

 

HeatherGLong
Frequent Visitor

I am still struggling with this.  Is there additional instruction?

This sounds awesome.  Have you made this yet as I'd love to see it for creating risk assessment documents?  Thanks, Simon

Hi there @Dr_Watts 

 

I did 😱 but forgot to share. Here is the link Create Dynamic Word Document with Power Automate & Microsoft Forms
https://youtu.be/8PUFodSc5BY

 

I’ve also put together a demo of dynamic population of strings in Power Apps also, using placeholders. Here it is also : Power Apps Dynamic Text Strings | Documents | Prompts | Paragraphs #PowerApps
https://youtu.be/Zex-jooO5io


Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

Hi @DamoBird365 ,

 

You are a star and I think this is going to come in very useful.  Still very much a newbie but just generated a work form for the engineers that will create dynamic (ish) documents for job methodology and risk based on a few inputs and then e-mail it to the client e-mail put in the form.

Once I get my head round these videos it will add another layer so many thanks.

 

Simon

Hi Damien, do you know if it's possible to conditionally delete a paragraph in a word template based on form data using Populate Word?

Hi @BVJB 

 

You cannot delete from Word, but you can conditionally include a paragraph. This is covered in my video above based on the sections yes/no.

 

Damien

Thanks Damien, great video! I have a few questions for ya... 🙂
1. Can I conditionally include headings to show in a formatted in heading style in the word report and is it possible to Page Break them to show on the next page?
2. How does this method deal with blank lines. e.g. if I have say 4 single line sentence options and I only want options 1 and 4 to show. Will there be two blank lines between 1 and 4 in the generated word report?
3. With my current software I have a 55 word template which has conditional deleting all through it (essentially allows me to have 1 template rather than 5 templates).  Could your method be a bit slow to generate the word document because of how many conditions I have. If so, would I be better of trying an alternative method like generating to HTML with conditional formatting then converting to Word from there? I really want a word report to generate that I can edit when need be. 

Cheers, Jamie. 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (987)