cazza162

Having a working and published document using Convert document action

Blog Post created by cazza162 Expert on Jun 13, 2016

Converting a Word Document to PDF

I am often asked about seperation of permissions with working and published documents, and a way of doing this nicely with workflow is to use the Convert document action.  We have many instances within the business where a small team have access to a "working" document library but push finalised and approved documents to an open document library for all authenticated users to consume.  We will use this scenario for the working example below.  We will have our "working" document library called Read Write PDF and have our "published" document library called Shared Documents.  All users will have access to read the content of Shared Documents but only team members will have access to Read Write PDF.

  • Navigate to the Read Write PDF 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 change the file name of the document we are working on to remove the .docx extension and replace it with .pdf (as when we configure the Convert document action later we will need the full name including extension).  We can do this by adding a Regular expression action to the workflow.
  • The Regular expression action requires a variable to put the output value into, so we need to create a variable.
  • Drag the Regular expression action to the first design node on the workflow and double click to open the configuration options.
  • To create a variable for the output of this action, select Variables in the ribbon of the Regular expression action to open up the Workflow Variables window.  Select New in the ribbon and create a variable as below:

vTextFileName.PNG

  • Select Save and then close the Workflow Variables window to return to the configuration of the Regular expression action.
  • Configure it as follows:

RegularExpression.PNG

  • So now we have the name and extension of our newly created pdf, we need to actually convert the document into a PDF and place it into the Shared Documents library.  Add the Convert document action to the next design node on the workflow and double click it to open the configuration settings.
  • Configure the item as follows, ensuring that the Output URL is https://xxx/sites/busitc/Nintex/Shared%20Documents/{vTextFileName} - replacing the bold area with the variable created earlier by using the insert reference book and selecting Workflow Variables.

ConvertDoc.PNG

In this example I have decided to catch the errors (if any occur) in the above action and store the occurrence and text in variables called vBoolError (did the error occur) and vTextError (what was the error).

I will use a Run if logic action to log the details of the error to the history list if an error occurred.

  • Add the Run if action to the next design node on the workflow and double click it to open the configuration window.

RunIf.PNG

The idea behind this is that we want to check if our newly created variable vBoolError is equal to yes, which would imply that the Convert document action errored.

The configuration above checks if the variable vBoolError = yes

Inside the Run if action, I use Log in history list action to log the reason for the error in the message body by referencing the variable vTextError

LogInHistoryList.PNG

Add any additional actions as required to your workflow.  Change the start up options as required (in this example we were happy with a manual start but this could be done after multiple approvals for example) and Publish.

Outcomes