cazza162

Write to Documents using the Update document action

Blog Post created by cazza162 Expert on May 20, 2016

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.

EditTemplate.png

  • 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.

ContentControls.PNG

  • 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.

ContentControlProperties.png

  • 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:

NameDescription
ctReviewerThe ID of the person who completed the review task
ctReviewDateThe date and time of completion of the review task
ctApproverThe ID of the person who completed the approval task
ctApprovalDateThe date and time of completion of the approval task
ctReviewerCommentsThe comments left (if any) on completion of the review task
ctApproverCommentsThe 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

AssignFlexiTaskReviewer.PNG

  • 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

AssignFlexiTaskApprover.PNG

  • 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.

UpdateDocumentReview.PNG

  • 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.

UpdateDocumentApprove.PNG

  • 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.

RejectionNotification.PNG

  • 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:

UpdateWF1.PNG

UpdateWF2.PNG

  • Save and Publish the workflow giving it a descriptive title.


An example output of successful review and approve inside the document looks like this:

DocumentUpdated.PNG

Outcomes