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