This is a blog post about how we created and stored PDF reports in SharePoint generated from Dynamics 365 data.
Our client is a manufacturing company. After the sales staff visits a client, they are required to fill out a “Visit Report” so that others in the company can review their information. Our client wanted to store these reports in SharePoint because Dynamics 365 licenses are more expensive than the general Office 365 licenses, which SharePoint is a part of.
Visit Reports were created as an entity related to accounts in the Dynamics 365 system.
- Set up Document Management sync between Dynamics 365 and SharePoint Online.
- Create a content type in SharePoint and associate a Word template with it.
- Go into Microsoft Flow and create a blank flow.
- Add a “trigger” from Dynamics 365 which will launch the flow whenever a record is created or updated in Visit Reports.
- Add an “action” from Dynamics 365 to get a record from the Account entity.
- Select the correct organization name (i.e. your company’s main tenant; ours is “MRS Company Limited”), select “Accounts”, and for the Item Identifier, we chose “Customer” from the list of dynamic content.
- Add an action to “Get file content” from SharePoint library Visit Report. This will be the blank template for Visit Report.
- Flow will prompt you for the site address and file identifier. Under site address, select/enter the URL for the SharePoint site. For File Identifier, select the template from the library location.
- Add another action step to create the file in the SharePoint library “Visit Reports”.
- Under site address, enter the URL for the document’s destination location in SharePoint. For the folder path, select the exact library. In this case, it is “/sti_visitreports”. For File Name, select Account Name from the Get Record step (see above) and Visit Date from the date the location was created/updated. For File Content, select File Content from the Get File Content step. See screenshot below:
- The final step is to add an action to update file properties. From here, select the URL and SharePoint document library, and then enter the ItemID from the Create File step. At this point, you can add in any metadata that is required via the dynamic content tab.
- Click save and start testing!