This post is part of a series where we examine the advantages and disadvantages of a document approval process, and then build an example automated solution with SharePoint and PowerAutomate.
Posts in this series:
- Should you automate your document approval process?
- Building a basic document approvals automation with SharePoint and PowerAutomate
In the previous step we created a new PowerAutomate Flow that will be triggered by a member of the Finance authoring group to request that a document is approved for publication.
So far, the flow has been configured to send an email to an approver, asking they either Approve or Reject the document.
In this step we handle processing the document if it has been approved for publication.
Adding the PowerAutomate Flow Condition action to check if document has been approved
If a document is approved for publication, then it must be converted to a PDF file and uploaded to the Published Documents Repository SharePoint site.
First we need to check which option the approver selected from the email they received: Approve or Reject.
To do this, add a new action following the Send email with options action and filter for condition. Choose the Condition action from the Control connector.

The Condition action will test a condition to see if it is true. If true then one set of actions will be executed, otherwise a different set will be executed.
Name the condition action to better describe what is being tested. For this condition we use the name, Document approved.
We need to test whether the option chosen by the approver is Approve or Reject. To do this select a value to be examined – the body/SelectedOption output from the Send email with conditions action.

We then need to set the value we are testing the body/SelectedOption output against. In our case it is the value, Approve.

Read information and content for the approved document
If the condition action’s test finds that the document has been approved, then we will need to convert the document to a PDF file and upload it to the Published Document Repository.
Before we can carry out the PDF conversion, we need to read the approved document’s metadata and content.
To retrieve the document’s metadata, click the + icon in the True branch of the condition action and search the actions list for get file properties.
Select the Get file properties action from the SharePoint connector.

Set the parameters of the Get file properties action.
Values for the Site Address and Library Name parameters can be copied from the trigger. Remember, you may need to choose Enter custom value if the SharePoint site is not given as a option in the drop-down list.
For the Id parameter, place the text cursor in the parameter value text box and then click on the lightning icon to select the ID (File Identifier) dynamic content item.

Next, add a new action after the Get file properties action.
Search for and select the Get file content action from the SharePoint connector.
Set the Site Address parameter for the action to match the trigger.
The File Identifier parameter is different to the Id parameter used for the Get file properties action. To set this property, click the dynamic content icon (lightning icon) and then search for identifier.
Choose the Identifier output from the Get file properties action.

Create a temporary copy of the file in OneDrive and convert to PDF format
The PowerAutomate OneDrive for Business connector provides an action to convert a file to various formats, including PDF format.
[Note: the OneDrive Convert File action is in Preview so may change in terms of availability or function in future.]
The OneDrive Convert File action only operates on files already in OneDrive. We therefore need to copy the approved file to OneDrive. That is why we read the content of the file in an earlier action.
Add a new action by click on the + icon under the Get file content action and search for create file. Select the Create file action from the OneDrive for Business connector.

The Create file action is going to be used create a temporary file in the current user’s (Lynne’s) OneDrive.
Rename the action to Create temporary file in OneDrive to better indicate the action’s objective.
The temporary file will be created in the root of OneDrive, so set the Folder Path parameter to / (forward-slash). [Note: you may need to tap the escape key after typing the forward-slash key to cancel any pop-up menu.]
The temporary file’s name shall use a randomly generated prefix to avoid clashing with any other file’s that might already be in OneDrive. The prefix shall consist of 4 randomly generated digits.
To specify the prefix, click in the File Name parameter’s text box and then click the ‘fx’ icon to open the expression editor. Enter the following as the expression and then click the Update button:
rand(1000,10000)
The purpose of the above is to produce a randomly generated number from 1000 up to (but not including) 10000. This gives us the 4-digit random prefixed for the new file’s name.

We then need to select the original file name to be concatenated with the random prefix.
To do this, click in the text box for the File Name parameter to the right of the rand expression and click the lightning icon to insert dynamic content.
Search dynamic content for extension and then select the File name with extension output from the Get file properties action.

The File Content parameter is configured with the File Content dynamic content item from the Get file content action.

Create a PDF version of the temporary file in OneDrive
With a temporary copy of the approved document in OneDrive, we can now produce a PDF version.
Add a new action following the Create temporary file in OneDrive action and search for convert file.
Select the Convert file action from the OneDrive for Business connector.

The Convert File action’s File parameter should be set to the Id output of the Create temporary file in OneDrive action.
The Target Type parameter should be set to PDF.

When the Convert File action executes, it will read the contents of the specified file from OneDrive and create a PDF version of it.
The content of the PDF version will not be written to a file, but will instead remain as an output of the Convert File action which can then be used by other actions in the flow.
Writing the PDF file to the Published Documents Repository
At this stage of the flow, we have requested an approver review a document, received their approval and have created a PDF version of the document.
Next we need to write the PDF version of the document to the Published Documents Repository SharePoint site.
Add an action following the Convert file action and search for create file.
Select the Create file action from the SharePoint connector.

The Site Address parameter of the new Create file action should be set to refer to the Published Document Repository (PDR) SharePoint site.
The Folder Path parameter specifies the folder the new file will be created in. The default document library for a SharePoint site is available at path /Shared Documents.
We have created a folder called Finance in the PDR document library, therefore the full path of the folder is /Shared Documents/Finance.
The File Name parameter is set to match the name as the approved file, NOT the name of the temporary file created in OneDrive. When choosing the dynamic content item for the File Name parameter, ensure the Name from the Get file properties action is used.
The Name output from the Get file properties action does not include the file extension. We need to manually enter .pdf and the end of the File Name parameter.

The File Content parameter of the Create file action is set to the File Content output of the Convert File action.

Have we finished? We’ve produced a PDF version of the approved document and uploaded it to the Published Documents Repository (PDR).
The name of the uploaded document is the same as the draft document, but with the extension replaced with .pdf. What happens if a file with this name already exists in the PDR?
If a file with the name already exists, the Create file action will fail. In this case we would then want to overwrite the existing file with the new PDF content. We therefore need to add the Update file action from the SharePoint connector.

In the parameters for the Update file action we set the Site Address to the PDR, matching that used in the Create file action above.
The Update file action differs from the Create file action in that is requires File Identifier parameter rather than Folder Path and File Name parameters. As it happens, even if the Create file action fails, it will provide the needed file identifier in its outputs.
We set the File Content parameter to match that used in the Create file action.

The Update file action has only been added to the flow to handle cases where the Create file action has failed. We don’t want the Update file action to run when Create file has been successful.
To control when the Update file action is run, access the Settings and configure the Run after rules. Ensure that only the Has failed option is selected.

Clean up temporary files in OneDrive
Before we generated a PDF version of the approved document, we needed to copy the approved document to a temporary file in OneDrive.
Our last step in this flow is to clean up that temporary file. We’ll do this by adding the Delete file action from the OneDrive connector.

The only parameter needed is the unique identifier for the file in OneDrive.
We populate this parameter with the Id dynamic content item output from the Create temporary file in OneDrive action.
