web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Populate a Microsoft W...
Power Automate
Answered

Populate a Microsoft Word Template and ALM limitations

(1) ShareShare
ReportReport
Posted on by 672
 
 
In my dev environment, I have successfully configured the Populate a Microsoft Word Template:
 
Location: via the dropdown control
Document Library: again the dropdown control
File:  hardcode .docx filename 
 
 
 
 
So to make the Power automate in my solution, deployable to test
 
Location:  I can set this a SharePoint Datasource environment variable 
 
Document Library:  now here is the kicker, this can't be an environment variable  and has to be selected via the dropdown control.  So is the strategy to have separate folders per the dev, test and prod environments, since the document library is fixed? 
 
FIle:  set to text environment variable or even Compose action ( if it never changes).
 
 
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    Valantis Profile Picture
    5,355 on at
     
    you don’t need separate folders per environment.

    The Document Library field can’t take an environment variable through the dropdown, but you can get around this by using Peek code on the action. That gives you two GUIDs  one for the drive (document library) and one for the file. Store both as Text type environment variables in your solution. Your Location stays as a Datasource environment variable as you already have it.
    For each new environment (test, prod), the steps are:
        1.    Upload the same Word template to that environment’s SharePoint.
        2.    Create a throwaway flow there with the Populate Word Template action, point it at the correct library and file, then use Peek code to grab the drive and file GUIDs. You can delete the flow without saving.
        3.    After importing your solution, update the two Text environment variables with those GUIDs. The Datasource variable for Location you just pick from the list as normal.
    That’s a one-time setup per environment. After that, future solution imports don’t need any changes to the environment variables.
    For the File field specifically  if the filename never changes, a Compose action works fine, or just keep it as a Text environment variable for consistency.
    Hope that unblocks you.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

  • westerdaled Profile Picture
    672 on at
     
     
    Thanks for your suggestion.   I have stored the both  the  filename, file and drive values in a json array in my text environment var.
     
    However, looking at the code view , it seems the file and location seem quite stable , so just the drive to change. Then I hit the issue that if the drive is stored in a variable , compose, or enviroment variable it doesn't get evaluated at design time so my template placeholders are not revealed to me. 
     
    I tried to fool the uI but selecting the document library and setting a few template parameters, then replacing my drive variable. Then my placeholders dissappear.  
     
     
     
     
     
     
     
     
     
     
     
     
  • Suggested answer
    Valantis Profile Picture
    5,355 on at
     
    The screenshot confirms the variable is working correctly in the code.
    The placeholders disappearing from the designer is just a UI limitation the designer cannot evaluate the variable at design time so it cannot render the placeholder fields visually.
     
    But at runtime it works fine because the variable gets resolved then.
     
    The approach to get around this:
    1. Temporarily hardcode the drive GUID pointing to dev
    2. Select the document library and file so all placeholders appear in the designer
    3. Map all your placeholder fields
    4. Then swap the drive back to your variable
     
    The placeholder mappings stay in the JSON even after the designer stops showing them.
    So the flow will run correctly in all environments. You just lose the visual comfort of seeing the placeholders in the UI.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

  • westerdaled Profile Picture
    672 on at
    Hi 
     
    @Valantis
     
    Not sure what you mean about the drive guid pointing to Dev, but both location and filename are selected via the UI 
     
    I first select the document library and set a couple of placeholder fields ( out of 20) .  I run the flow and I can see they are being set in the output of Populate 
    Word Template action.
     
    I then change to document library to varDrive which does have the hardcoded value - I have compared the value with my json arrary in VSCode and it is perfect. 
     
    [{
    "fileName": "Dans_Dodgy_Document_Demo_v2.docx",
    "drive": "b!D_q_sTcjFkaBcuiwy7ycYzBgXR.....",
    "file": "01X27A6HIQQWHYG....."
    }]
    
     
     
    However, the UI is not to be fooled .....
     
     
     
     
     
  • Suggested answer
    Valantis Profile Picture
    5,355 on at

    it seems that the drive variable is working correctly.
    The error is most likely the file GUID in your JSON array is pointing to the wrong file or a stale version.
    When you previously tested with the hardcoded drive the UI resolved the file correctly, but the file GUID in your JSON may not match the current file.

    Check the file GUID in your JSON against the actual current file.
    If you re-uploaded or renamed the template at any point the GUID changes and you need to update it in the JSON.
    let me know ,If the GUID is correct and the issue persists...
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

  • westerdaled Profile Picture
    672 on at
     
     
    The guids in the json array are correct. Indeed, when I post the drive guid into the Document Library property in the Populate Word Template action, it resolves the template doc library. 
     
    The template filename hasn't changed, nor has its giuid.  
     
    I am thinking, that even if we got this working, there is no way I can leave the dev team to maintain the Power Automate if they can't see the placeholder fields in the action.   I am rapidly thinking that I recommend a single template document libary but have different folders per environment.    
     
     
     
     
     
     
     
     
     
  • Verified answer
    Valantis Profile Picture
    5,355 on at
     
    Yes correct and that is actually the cleaner approach. One document library with separate folders per environment solves both problems at once.
    The drive GUID stays the same across all environments since it is the same library, so the designer can always resolve the placeholders and your team can see and maintain them normally.Only the folder path changes per environment and that is a simple text environment variable.
     
    try this strcture
    - Location: SharePoint Datasource environment variable (as you already have)
    - Document Library: hardcoded via dropdown since it never changes
    - File: text environment variable pointing to the correct folder path per environment
     
    One-time setup per environment is just uploading the template to the correct folder and updating the file path variable. Much more maintainable than the GUID approach.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

  • westerdaled Profile Picture
    672 on at
     
    Thanks for your help, I have now replaced the SharePoint site dropdown selection with the env var for the all the related actions and not just Populate Word Template.  Yes, you have go back and re-add the (20)  parameters.  The environment folder selection will go in a later sprint. 
     
    Was interesting looking under the hood of the Populate Word Template action.
     
     
    Daniel
     
     
     
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 791

#2
Valantis Profile Picture

Valantis 582

#3
Haque Profile Picture

Haque 529

Last 30 days Overall leaderboard