Picking up where the Automatically export audits with MS Flow guide left off, we will extend the flow to automatically upload audit reports to SharePoint.
Add an action within the Apply to each loop and after the Download an audit report step. We will use Get a specific audit to retrieve data from within each audit to name the files and folders in SharePoint.
Next, SharePoint’s Create file action will be used. Add it immediately after Get a specific audit and select your SharePoint site within the Site address drop-down field.
We can then choose a document library from your site to automatically folder your audit reports. To do this, click the folder icon to the right-hand side of Folder path. With your document library selected, click at the end of the text within the Folder path field and type a slash “/”. At this point, we can configure ‘dynamic foldering’ based on data within each of your audits. For the purpose of this guide, we are going to store audits by template.
Warning: Individual SharePoint lists, document libraries and folders can only contain a maximum of 5000 items. Dynamically foldering your exports is necessary for this reason as it spreads your exports across multiple folders and avoids reaching the limit.
Using a part of the date of each audit (e.g. the Month an audit is completed in) is another option for your folder names.
Go ahead and click in the Folder path field again, after the ending slash “/” and then click Add dynamic content. To folder based on the template an audit was created from, choose the Template Name dynamic content. Here’s what you should end up with:
We can also use dynamic content to name the audit report file based on data within each audit too. This guide will set up filenames so that the audit author, date completed and score percentage, are used. Doing so involves clicking the File Name field and then choosing Audit Author, Date Completed and Score Percentage from the available dynamic content listed under Get a specific audit.
You may have also noticed from the screenshot above that we have manually typed hyphens “-” between each of the selected dynamic content and also “.pdf” at the end.
All that remains is to click the File Content field and select Audit Report from the dynamic content provided by Download an audit report.
Tip: You could also use a combination of SharePoint’s Create item and Add attachment actions to create new list items with data populated from the audit and the audit reports attached.
And the end result: