Write to Documents using the Update document action
This action allows you to write to Content Controls inside a Microsoft Word document. I am very often asked if it possible to put an approval stamp on the document itself, rather than having the approval in the metadata of the document in the library. The short answer is yes (although this will not be a signature, it will be the user ID of the approver and the date and time of approval). Below you will see the steps needed to achieve this.
Step 1: Edit the template for the document in the document library
The document that is added to the document library needs to have the content controls in the template for Nintex to work with. We therefore need to edit the template associated with the document library. You can do this as follows:
- Navigate to your document library, and access the Library Settings through the Library tab in the ribbon
- Select Advanced settings under General Settings.
- In the Document Template section, select Edit Template.
- This will open the document library document template in Microsoft Word. In order to add Content Controls to the template, you need to have the Developer tab visible in the ribbon. If this is not already visible, you need to
select File and Options to open the Word Options form. Select Customize Ribbon from the left hand menu. In the Choose commands from section, change the selection in the dropdown to be Main Tabs. Choose Developer in the left hand box and select Add>> to move it to the right hand box. Select OK to close the dialog. You should now see the Developer tab in the ribbon. - The Content Controls are visible in the Developer tab in the Controls section and are highlighted below.
- Add the desired Content Controls to the template in the desired locations.
- Each content control needs a name to work with the workflow. To name the content control, select it and choose Properties from the Controls section in the Developer tab. Add the same name to Title and Tag fields in the Content Control Properties form ensuring there are no spaces. It is advisable to make a note of what you name them as you will need to type these names into the workflow configuation later.
- Ensure all controls are named and the template is as you wish before selecting Save. Close Word.
- Test the template has saved by selecting Documents tab in the ribbon on your document library, then New Document.
Step 2: Create Workflow to write to the document
Now that the template is in place, the workflow is able to write to the content controls within it. In this demo, I have created content controls as follows:
Name | Description |
---|---|
ctReviewer | The ID of the person who completed the review task |
ctReviewDate | The date and time of completion of the review task |
ctApprover | The ID of the person who completed the approval task |
ctApprovalDate | The date and time of completion of the approval task |
ctReviewerComments | The comments left (if any) on completion of the review task |
ctApproverComments | The comments left (if any) on completion of the approval task |
I will use these controls when a document has been positively through the review and approval processes in the workflow.
-
- Navigate to the document library and select Library tab in the ribbon, Workflow Settings and Create a Workflow in Nintex Workflow.
- Select the blank template.
- We want our document to go through review (to the Demo Reviewers SharePoint Group) and approval (to the Demo Approvers SharePoint Group) so we need two Assign flexi-task actions on the designer.
- Double click the action to configure the first Assign flexi-task action as follows
- Note the above task has been assigned to a SharePoint group, but I have selected to Create individual tasks in order to capture who actually responded to the task to push into the document.
- Double click the action to configure the second Assign flexi-task action as follows
- Note the above task has been assigned to a SharePoint group, but I have selected to Create individual tasks in order to capture who actually responded to the task to push into the document.
- In this example, we want to update the content controls inside the document only when the flexi tasks have been approved. Drag an Update document action to the approval branch of each Assign flexi-task action.
- For the approval under the review Assign flexi-task we need to configure the Update document action to update only the content controls assigned to the review data. Double click the action to configure it as below, ensuring that the names entered into the configuration match those you entered into the document template for the document library.
- In the above configuration we are updating the content control ctReviewer with the system variable Last Task Respondent Display Name which is accessible using the insert reference book and looking under the Common tab. This will give you the display name of the person who responded to the most recent task associated with this workflow. We are updating the content control ctReviewDate with a concatenation of the system variables Current Date and Current Time to build the date and time of approval. These are inserted using the insert reference book and looking under the Common tab. Finally we update content control ctReviewerComments with the system variable Approver Comments which outputs the comments from the most recent task responded to in the current workflow and is added using the insert reference book under the Common tab.
- For the approval under the approval Assign flexi-task we need to configure the Update document action to update only the content controls assigned to the approval. Double click the action to configure it as below, ensuring that the names entered into the configuration match those you entered into the document template for the document library.
- In the above configuration we are updating the content control ctApprover with the system variable Last Task Respondent Display Name which is accessible using the insert reference book and looking under the Common tab. This will give you the display name of the person who responded to the most recent task associated with this workflow. We are updating the content control ctApprovalDate with a concatenation of the system variables Current Date and Current Time to build the date and time of approval. These are inserted using the insert reference book and looking under the Common tab. Finally we update content control ctApproverComments with the system variable Approver Comments which outputs the comments from the most recent task responded to in the current workflow and is added using the insert reference book under the Common tab.
- To finish the workflow off we need to add some Send notification actions on the reject branches to let the initiator know that the document was rejected at review or approval stages. Use the system variables mentioned above to ensure that the initiator knows why the document was rejected.
- After the email has been sent on the rejection branches we want to end the workflow using the action End Workflow.
- Finally, I have added a Send notification action at the very end of the workflow to inform the initiator that the document has successfully gone through review and approval stages. The finished workflow looks like this:
- Save and Publish the workflow giving it a descriptive title.
An example output of successful review and approve inside the document looks like this: