Our use case:
- A word file needs to be generated everytime a new application is submitted – with some fields that come from the application form such applicant’s first name and last name.
- Someone reviews the request, performs manual updates to the file and sends it for approval.
- When the file is submitted for approval, 2 more fields in the application word file must be filled out and this file needs another update.
The template needs to be generated and our automation will fill out the initial fields when the application is created, but after approval we need to write into 2 additional fields (approval details and due date) on top of this existing file.
Solution
- Create a MS Word template with the fields you need to fill out
- Create a SharePoint list that will be used to record applicant’s information
Workflow #1. When application record is created
Step 1. Trigger
Step 2. Populate Word template with the initial fields
Step 3. Create template file and save in SharePoint
Save the file with the ID as File Name.
Workflow #2. When application is approved
Step 1. Trigger
Make sure to add a contidional in the Trigger settings, to avoid this automation running for undesired scenarios.
Step 2. Send approval and wait for outcome
Step 3. Update the existing template using file Path and Fields ID.
How to find the fields ID?
Create an empty step to populate the Word template, making sure you select the base template. Click on the right corner dots and then Peek code.
You will see below code, just look for the text “dynamicFileSchema” and find the number/id that belongs to the fields you are looking to dynamically populate.
Finally, create a JSON structure like below, using the ID as the attribute names