Skip to main content

Read from Documents using the Read document action

This actions allow you to read from Content Controls inside a Microsoft Word document.  When documents in a document library have these controls, Nintex Workflow has the ability to work with these controls.

Below you will see the steps needed to achieve reading from the Content Controls in a Word document.

 

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 read from the document

Now that the template is in place, the workflow is able to read from the content controls within it.  In this demo, I have created a content control called ctProject to store the Project number on the document itself (not within the document metadata).  I will use this project number to find the Project Manager and email them when a document is added.

  • 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 need to store the information we read from the document in a variable, so we need to create one.  Select the Workflow Settings dropdown and choose Variables.  Create a new variable of type Single line of text called vTextProject.  Save and Close the variables window.
  • Drag a Read document action onto the first design node in the workflow designer.  Double click the action to open the configuration options.
  • Configure the action to read from the current document, specifying the name of the content control and the name of the variable to store the data in as below.

ReadDocumentConfig.PNG

  • In this example, I am going to use this variable to look up the project manager to send them an email.  To do this, I need to query the Projects list using the variable above and pull back the Project Manager.
  • We need to store the information we read from the Projects list in a variable, so we need to create one. Select the Workflow Settings dropdown and choose Variables. Create a new variable of type Person or Group called vPersonProjectMgr. Save and Close the variables window.
  • Drag a Query list action onto the next design node in the workflow designer. Double click the action to open the configuration options.
  • Configure the action to query the Projects list where Project is equal to the variable vTextProject.  Pull out Project Manager and store in vPersonProjectMgr.

QueryList1.PNG

QueryList2.PNG

  • Finally, let's email the Project Manager and cc the initiator of the workflow.  Add a Send notification action to the next design node and configure it as follows:

SendNotification.PNG

 

 

To see this in action, create a document using the template in your library, ensuring the project number added to the document is valid in the list of projects and run the workflow.

 

Please note - naming conventions for labels are just my preferred way of working, other people have different ways.  This was covered in the most recent Nintex Hangout which is mentioned in this thread: Nintex Style Guide

Cassy,

Thanks for this - it has been very helpful!

I do have a question and wondering if you have any experience with it:

I've arranged the 'Read Document' action which finds the information and puts it into a workflow variable (I also read your best practice for the naming conventions which is also helpful as it's easy to get confused!). I then have an 'Update item' action to take those two variables and add them as metadata to the two columns I've got on my library.

It does this successfully, however I run into the following issues:

  • The default view is a grouped view via year and month and it has duplicated it rather than merge it with the other heading already there
  • When I attempt to expand the groups specific to the document I upload it doesn't expand that particular group (screenshot 1)
  • I can view it when I go into a non-grouped view and went to look at the properties, however it doesn't give me the option to edit the Month and Year column (screenshot 2)

Notes: The library doesn't have management of content types. I have tried this with 'Update item' and 'Set field value' but ran into the same issue.

Any guidance would be appreciated - not too sure if I'm doing something wrong or need to report it to IS.

Thanks

Screenshot 1 (document names have been black out):

Screenshot 1

Screenshot 2:

Screenshot 2


what data type is your column "Year"

looks like it is treating them as 2 different values even though on the face of it they are the same


On the Document Library I have the type down as a single line of text for the year and choice for the month. I've done the same when making the variable on Nintex.

Have you got any recommendations?

-Thank you


Thanks for your factful article Cassy!

You have highlighted, that the names of Content Control fields shouldn't have spaces in between.

However, I am working in some cases with auto-generated Word-Documents (by any applications), which include Content Control field names - such as "Wiki Control".

Is there any workaround for reading from such fields, as I don't have any chance to influence the naming of those auto-generated Content Control fields?


Kind Regards,
Steffen 


Reply