dox42 in a Sharepoint / Nintex environment : PDF conversion through the REST services

 

Context

During one of our projects, our customer had the following requirement : to differentiate work-in-progress files (Excel, Word, Powerpoint) and referential files (PDF). With SharePoint, Nintex and dox42 Enterprise, we decided to build a single Nintex workflow to manage the conversion aspects.

Main requirements

  • Store the working files and the referential documents in two separate containers
  • Preserve the metadata attached to the working item

What we want to achieve

We want to design and implement a Nintex workflow which manages all the cases described above.

Hypothesis

In the following description, we assume that you have a running dox42 Enterprise Server and that you are able to design Nintex Workflows in your technical environment.

We use Nintex Workflow 2016 Enterprise Edition. All components used in this process are available in the Standard Edition.

stepsStep 1 : Prepare the Environment

We assume that we have two Document Libraries on our Sharepoint site :

  • DocumentsWIP
  • Referential

Our Nintex Workflow will be set as a List Workflow on DocumentsWIP. The start condition can be manual or triggered in regard to your own constraints or flow.

In the environment, we will create Nintex variables as follows:

table_01

First, we will assign the variable with the metadata that have to be kept :

The Variable DocFields contains :

SharepointAction.Field1.Name=InternalNameOfTargetField&SharepointAction.Field1.Value={ItemProperty:Value}

You can combine some fields by adding the character & and increment the value of the field (such as Field2, Field3…)

Example with 2 fields to populate :

SharepointAction.Field1.Name=InternalNameOfTargetField&SharepointAction.Field1.Value={ItemProperty:Value}&SharepointAction.Field2.Name=InternalNameOfSecondTargetField&SharepointAction.Field2.Value={ItemProperty:Value3}

Secondly, we will store the “FilePath” of our source file (ie. the full URL of the file without its extension (which in our case is stored in the ItemProperty:Nom). The variable FilePath contains :

{Common:WebUrl}/{WorkflowVariable:SourcelistName}/{ItemProperty:Nom}

This step in the workflow designer looks like this :

fig_01

  

Step 2 : Identify the name and the type of document

In the next steps, we’ll need to know :

  • The extension of the file. This one will be mandatory to use the good target URL.
  • The filename without its extension. The real name of the file will be used in the request

So we will extract these parts from the ItemProperty FileLeafRef.

For the Filename :

fig_02 

For the FileExtension :

fig_03

For each of the intermediate variable, we will use a collection operation to get data at index CollIndex.

At the end of this step, we have the following variables full :

  • FileName
  • FileExtension

This step in the workflow designer looks like this :

fig_04 

Step 3 : Generate a Datamap (required only for Spreadsheet conversion)

We will create a new Document Library with limited rights, in our case we will name it Dox42_temp.

For Spreadsheet Generation, we need to have a specific datamap. For this purpose, we will generate a custom datamap for the Spreadsheet we want to convert.

First, we need to generate a template datamap for our context (typically for the credentials). We do this by creating a new Excel File and through the dox42 ribbon set the datamap. In it add 2 main components :

  • A crypto data source with Username and Password
  • An Excel DataSource

The Excel Datasource is configured like the following picture :

fig_05The most important thing is to set the attribute output_excelfile to TRUE.

It is mandatory to use a real filename (ie. a real excel file). But as stated at the beginning our target is to do this for future documents and we don’t know their names yet. So take any excel File and we will do a trick. Then we can save the datamap and open it with any Code Editor.

It looks like this :

fig_06

 We took the whole content and copied it in a text editor. And we replaced the line <filename>…</filename> by the following :

<filename><![CDATA[]]></filename>

All the content has to be put into the default value of the variable Dox42DatamapTemplate.

fig_07

Then, in our process, if we have to work with an Excel file, we’ll create a specific datamap. For that purpose, we will replace (via a regular expression action) the pattern by the whole URL of the file (in my context, we assume that the file is available via a “public” URL)

The altered text will be put in a file which will be stored in the temp Document Library Dox42_temp. The url of the datamap is stored in the variable Dox42DatamapUrl and assembled as follows :

Site URL/Dox42_temp/FileName.dm

This is done by a Web request action set-up as follows :

fig_08

This step in the workflow designer looks like this:

 fig_09 

Step 4 : Construct the URL for a dox42 call

We have to construct the full URL of the call before executing it. This one can be elaborated from the dox42Server Test Client (You can read the following blog post on how to use it : https://blog-de.dox42.com/2018/05/15/dox42-flow-powerapps-getting-things-done/)

We do this through some actions which are executed in parallel. We set the variable Dox42PDFGenerationUrl.

In our context, the URL are constructed as described below and set in the variable :

(All elements in red are Nintex variables)

fig_10fig_11fig_12

This step in the workflow designer looks like this :

fig_13 

Step 5 : Call the service

In that step we have to add a Web request action in our workflow.

The parameters are like the Following :

fig_14

Be careful to only use credential which are allowed in the dox42 service.

 

This step in the workflow designer looks like this :

fig_15 

Step 6 : Enjoy the result

At the end, you can go to your Target List and show the documents stored by your dox42 service account (which needs rights to insert documents).

fig_16

In the version history, you can see the comment put in the request as well :

 fig_17 

 

Want to try it?

CONTACT US

For further information or questions, or an accompaniement prestation offer

 

Look for further information or request trial directly by

dox42-logo_trans

 

Share: