Share via


No code, Business process automation to generate Documents based on Templates

Abstract

Organizations have this need to implement a Business process to automate the approval and generation of Documents. While a generic process to implement this is extremely simple, with Office 365 SharePoint and Microsoft Flow, it is not uncommon to have requirements where the documents ought to be based on certain Templates, which is chosen by the requestor of the document. Also, while the approval workflow process would be bound to the Document Library, organizations would want to segregate the request capture process itself from the document generation and download. They may, for e.g. want the requestor to have read-only access to the document generated, while they could have read-write permissions in the Approval Request capture process.

Microsoft Flow, Powerapps and Office 365 SharePoint could be used to meet these requirements using an approach that entails zero code. Organizations could use these technologies to implement such automation without having to depend on internal IT to code such solutions, and at a fraction of the time that it would otherwise take.

Solution approach

Office 365 SharePoint Team Site is created that would contain several artefacts that are referred to in the sections below.

A custom List PolicydocsIssuanceRequests is where the Requests are captured. The Document requestor enters information like the Customer Name, the Document Type to be generated (whether it is a 'Statement of Work' format or whether it is a 'Warranty Details' format that needs to be created for the Customer), select a signatory (person who would approve this document generation request & the signatory). Selecting the Customer Name sets additional attributes like the Customer Address and their contact information automatically, using Look up fields that refer to a CustomersList Custom list. Requestors would have read-write access to the PolicydocsIssuanceRequests List, since they ought to be able to submit information.

PolicyDocsRepo is the Document Library where the Documents that are generated on approval get stored. Requestors would have read-only access to this Library. The same columns that exist in the PolicydocsIssuanceRequests List are created here too(see the screenshot below). A Microsoft Flow process bound to the PolicydocsIssuanceRequests List copies these attributes to the PolicyDocsRepo Document Library.

The PolicyDocsRepo Document Library should be configured to support Documents based on multiple Word 2016 Document templates. Authors of the Template ought to be able to access the field values in the Document Library and insert them as placeholders inside the document templates.

Use the guidance in this article to define the different Word 2016 document templates. From the Library Settings>Advanced Setting>, open templates.dotx. Edit the default template and make changes to it to suit each of the formats in this article (Statement of Work and Warranty templates), and save these as StatementOfWork.dotx & Warranty.dotx respectively to the PolicyDocsRepo Document Library.

The attributes from the Document Library are visible inside Word 2016 - (screen shot below). Place these fields in the relevant sections of the Document template.

To use these templates in a Microsoft Flow process, a Word 2016 document is created from each of the templates above and saved in the .docx format. To do that, simply open the .dotx templates from the Document Library and do a 'save as' to your local computer. Then upload these documents (e.g. in this article, the document names are as shown in the screenshot below) to the BlankPolicyDocuments Library.

Next, a Microsoft Flow process is configured on the PolicydocsIssuanceRequests List. Select the 'Start Approval when a new item is added' Template.

Post approval of the Request, based on the Template Type selected in the Request, the Switch/case branches out into a separate path.

The 'Get File Content' action under the path for 'Warranty', gets the WarrantyBlankFormat.docx from the BlankPolicyDocuments Library, and in the action Create File', inserts that into the PolicyDocsRepo Library. At this point it does not contain the column values from the Request submitted earlier.

The 'Update File properties' action, gets the link to the Document inserted in the 'Create File' action, and updates the column values in the Library with those captured with the initial Request. (screen shot below)

The 'RequestTrail' column value is set to the URL of the Request in the PolicydocsIssuanceRequests List, for trace back and reference.

To test the process, Create a new Item in the PolicydocsIssuanceRequests List, and use the default Edit Form the Custom list provides. However, to make the process simpler for the end users, from the list menu options, choose to create a Powerapps App for this List. The UI generation Engine builds the App automatically. Only minimal changes are required to be done. It uses certain attributes in the UI which you might not need. Just select those fields and replace them with the required fields from the Library. (See screens hot below)

Run the App and submit the request. Choose a Document template type (PolicyDocumentType in the screenshot below) to be used for the Document generation. An approval email is sent to the user selected in the 'Signatories' field in the App. Once approved, a document is generated and uploaded to the PolicyDocsRepo Document Library, using the Template chosen in the request.

Once the Powerapps App is tested, it would be published to Powerapps Service and then shared with other users in the Organization. Users would install Powerapps on their Android or iOS devices, and when they login with their Corporate credentials in Azure or Office 365 Active Directory, the published App would be visible to them.

Now users could submit this Document generation request even while on the move, using the Powerapps App on their Mobile phones or Tablet devices.