I'm posting this problem for the benefit of others as I wasn't able to find anything on this topic, but did manage to solve it (took me about a week with help from others)...
Problem Description:
I have a Power Automate Flow that will populate a MS Word Template and PDF the template. I can't use SharePoint due to company restrictions in using SharePoint for GxP use, so my MS Word template file is stored in Dataverse. My flow goes through the following steps:
- Download template file from Dataverse.
- Create the template file in OneDrive as a tmp file (the OneDrive of the user running the flow - this will be important later).
- Word Online Populates the template
- Delete the tmp File in OneDrive
- Create the populated file in OneDrive as a tmp file.
- Word Online Converts the file to PDF
- Delete the tmp File in OneDrive
For reference for # 3 & 6 above my initial (Erroneous) parameters were as follows:
With this configuration, when the Developer tests the flow, it will work, however when any other user attempts to run the flow Steps 3 and 6 will fail. with the following error:
The selected file doesn't exist, please select a valid file and drive.
Cause:
With the above configuration, the "Document Library" parameter is the problem. The default selection of "OneDrive" is not the OneDrive of the user running the flow! Rather selecting "OneDrive" will hard code the connector to the OneDrive of the DEVELOPER! Thus the flow fails when other users run the flow because the Word Online Connector is looking for the file that was just created by the flow in the OneDrive of the DEVELOPER, when in fact by using the "Create File" function of the OneDrive connector, the temporary file is being created under the OneDrive of the user running the flow. With these settings, Word Online will never actually find the file because it is looking in the wrong place.
Solution:
To solve this, the "Document Library" parameter must be dynamically set to reflect the OneDrive of the user running the flow. This can be done using the "File Locator" output from the step to create the file in OneDrive as follows:
split(outputs('Create_file')?['body/FileLocator'],'.')[0]