cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Documents using the Update document action

cassymfreeman
Nintex Newbie
10 22 11.3K

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

22 Comments
pramod_nagaraj1
Nintex Newbie

Hi Cassy,

This has been very helpful for me in the absence of Document Generation actions on the OnPremise version. I have been able generate dynamic documents and the business is fantastically happy.

Any idea on how to handle the repeating sections control?

I am required to iterate through a list and populate item values onto a repeating section content control in the word document which is in a certain format.

Please anyone who has any tips and tricks please let post and mention me.

Thanks

Pramod

vadim_tabakman
Nintex Newbie

Great post Cassy!!!

murphybp2
Nintex Newbie

Do you know, does this only work on the default "Document" content type?  I've created some custom site content types with custom templates, that have document controls.  However the controls are not getting updated by the workflow.  I don't get any errors...just doesn't get updated.

cassymfreeman
Nintex Newbie

Brendan Murphy​ be good if you could start a new discussion with some screenshots of your workflow configurations for us to start troubleshooting.

murphybp2
Nintex Newbie

So I’m assuming that means you have been able to get it to work on custom content types and not just the default template? That’s really my question before I go opening an issue.

cassymfreeman
Nintex Newbie

I will have a play over the weekend  

suolon
Nintex Newbie

This is for On-prem.... any similar solution for O365 online version?

clxwas3
Nintex Newbie

Hello, Cassy!

Do you know how to update document with 'Repeating section content control' ?

Thanks in advance.

obaidaaqel86
Nintex Newbie

HI @Shiyao Wang

 

did find solution for 'Repeating section content control' ???

obaidaaqel86
Nintex Newbie

Hi @Pramod Nagaraj 

did find solution for 'Repeating section content control' ???

clxwas3
Nintex Newbie

Sorry, No...

pramod_nagaraj1
Nintex Newbie

Nop not really.

But I read somewhere that the document template can be read as XML and repeating section element to be update with the information you need to display.

I am not sure if there's any option with the very latest release of the Nintex Workflow 2013.

cassymfreeman
Nintex Newbie

So sorry I didn't see this to reply.

You could break up your XML and use the normal content controls but you would have to add a fixed number of controls in word which obviously you don't know how many rows there are in a repeating section...  so it's a bit difficult.

I believe Nintex Document Generation can do this - have you looked at this?

clxwas3
Nintex Newbie

Hello,

You can refernce to this action:"Document Generation"

http://vadimtabakman.com/nintex-workflow-history-list-size-report.aspx

pyae
Nintex Newbie

Thank you for your contribution. It's really helpful. At the beginning I was trying to find the content control in the current items, confuse with where to find it. Finally I put the control name by manually and assign the value in it. It works.

brightlight
Nintex Newbie

Cassy Freeman‌, Is there a way to insert signature into word template content control. For signatures created using blogs created by great minds like below:

Sign your name across my heart 

Embedding Signature Pad in Nintex Form 

New! Easier way to add a signature capture 

This will altogether remove for us to use document generation action and not have to pay for it (i am being a bit stingy here).

It inserts the generated blob into rich text control but i do not know how to display the signature in word. When i paste the generated blob into the: https://codebeautify.org/base64-to-image-converter, i get the exact signature.

I would also like to use repeating section and such in near future, if possible.

cassymfreeman
Nintex Newbie

I don't think there is a way to do it.  repeating sections are possible but quite long winded to pick apart the xml and put it into the word doc.  if you have docgen already I would keep it - I would much rather use that than do this long winded process for creating a word doc!  also docgen lets you use excel and powerpoint and doesn't limit you to just word.

brightlight
Nintex Newbie

Thank you Cassy Freeman‌, i do have the document generation action on my workflow yet, i will have to update my workflow. I hope document generation will be what i expect it to be without not causing too much bang on the buck. I am also testing Muhimbi, which is a great document generation tool for SharePoint/nintex with extra features like watermarking and security.

cassymfreeman
Nintex Newbie

Yeah we use muhumbi it’s great for collation and conversion. I’m sure it had print to pdf though I’ve never tried it yet. I’ve seen demo’s of docgen and it looks easy peasy - let me know how you get on  

harve019
Nintex Newbie

How does this work if you want to have more than one document template?

rhia
Nintex Newbie

The "Update Word Document" action isn't available in O365. You need to use Document Generation - you may have 500 free generations before you need to purchase a package for it.

rhia
Nintex Newbie

Hi Liz Harvey‌, 

If you are using the Update Word Document action in On-Prem, your only way to handle more templates is by having a switch in your workflow and creating an Update Word Document action per template, and use the switch to choose which template needs to be used.

In O365 with Document Generation, you can use several templates int he same action and put your logic within that.

Cheers,

Rhia