Using Copilot And Power Automate To Create Records - Power Platform for Educators (Ep. 9)
Inserting Dynamic Tables into Word Templates from Power Automate
Introduction
Nate Halliwell is on the nifty task of inserting dynamic tables or repeating sections into Word templates using Power Automate. Let's dive into the world of repeating sections and tables!
Setting the Stage
In our scenario, we're revisiting the asset tracking scenario—quite a common use case. The goal? Send out Word templates to employees, listing their assets along with due dates for each. Monthly or annually, this could serve as a friendly reminder to return the assets on time.
Crafting the Word Template
The journey begins with a simple Word document, and to make things dynamic, Nate starts by adding a field for the employee's name. This isn't a repeating section; it's just a single dynamic field. Using the developer tab, a plain text control is added, named 'full name,' ready to be populated later in Power Automate.
Inserting the Dynamic Table
Now comes the star of the show—the repeating section. Nate inserts a table into the Word template to capture all the individual employee assets. With three columns for asset type, manufacturer, and due date, the header row is styled to give it that table look.
Adding Input Fields to the Table
The next step involves adding input fields for each row in the table. For asset type, manufacturer, and due date, plain text controls are inserted and appropriately named. These will later be mapped to corresponding fields in Power Automate.
Transforming into a Repeating Section
The magic happens when our speaker selects all three fields, goes to the developer section, and adds a repeating section. This transforms the table into a repeating section, aptly named 'asset items.' Remember, in the Power Automate world, a repeating section or table is essentially an array.
Mapping Fields in Power Automate
Now, let's switch gears to Power Automate. Nate has a flow set up, pulling data from SharePoint lists of asset holders and asset managers. The goal is to filter assets for each employee and create an array variable to pass into the Word template.
Filtering Assets in Power Automate
The first step involves filtering the asset manager table based on the current asset holder. Using logical names and filter queries, the flow ensures that each employee gets a tailored list of assets assigned to them.
Initializing and Appending to the Array
To prepare for the dynamic array, Nate initializes a variable named 'V items' at the top level of the flow. Inside a loop, the flow iterates through each asset, appending its details to the array variable. Notably, the array is reset before processing each new employee to avoid cumulative data.
Crafting the JSON Array
In a notepad, Nate drafts a JSON array structure, keeping in mind the asset type, manufacturer, and due date fields. This array will be dynamically populated with data from Power Automate and fed into the repeating section in the Word template.
Testing and Wrapping Up
With the setup complete, Nate runs a quick test to ensure the syntax is correct and everything is functioning as expected. The flow intelligently retrieves asset details for each employee, creates a dynamic array, and passes it seamlessly into the repeating section of the Word template.
Conclusion
And there you have it! A streamlined process for inserting dynamic tables into Word templates using Power Automate. It's a game-changer for scenarios like asset tracking, making communication with employees about their possessions more efficient. If you're venturing into the realm of dynamic Word templates, this approach is definitely worth exploring.
That's a wrap for today's tutorial! Don't forget to subscribe to the Pragmatic Works' YouTube channel for more practical insights into Power Automate and other tech wonders. And if you want access to even more courses, then sign up for the Pragmatic Works' on-demand learning platform today!
Sign-up now and get instant access
ABOUT THE AUTHOR
Nate Halliwell is a Power Platform enthusiast, specializing in Power Apps and Power Automate. He began his journey into the Power Platform as a “Citizen Developer” while working as a recruiter in talent acquisition. He used Pragmatic Works to train himself on the technology and hopes to use this new role as a trainer to help others achieve similar career transitions! Nate is PL-900 and PL-100 Certified, and ready to help you take on any Power Apps or Power Automate challenges you or your organization are currently facing! Outside of work, Nate is a husband, a father to 2 boys, and a beer league hockey player.
Free Trial
On-demand learning
Most Recent
private training
Leave a comment