Nintex for Office 365 – Document generation with repeating section
avatar

At the end of the last year Nintex released a new workflow action for Office 365 called “Document Generation”. This action offers the opportunity to create documents based on a definable template with all the information that is gathered while the workflow is running (If you’re interested in the announcement you can find it here).

After the release I’ve asked myself whether it is the possible to get the information of a repeating section (created with Nintex Forms for Office 365) into a document via the “Document generation” action. The answer is yes and in this blog post I’m going to show you how this can be achieved.

The focus of this blog post will be the workflow including the „Document Generation“ action, but for a better understanding I will also describe the other aspects of my scenario. There’s a custom SharePoint list with a Nintex form which offers the opportunity to order products in the desired quantity. Afterwards a workflow will automatically create a PDF document with all relevant information concerning the specific order. The PDF document is created based on a predefined Word template.

SharePoint List and Nintex Form

First, I create a custom SharePoint list called „Orders“ with a choice column „Product“ that includes different products and a multiple text column called „OrderedProductsandQuantity“. I modify the form of this list via Nintex Forms and add a repeating section that includes the „Product“ column as well as a new single line textbox control called „Quantity“. The information of the repeating section (the XML) will be stored in the column „OrderedProductsandQuantity“.

image

This is the XML that is stored in the column „OrderedProductsandQuantity” for the example shown in the previous screenshot:

<?xml version=“1.0″ encoding=“utf-8″?><RepeaterData><Version /><Items><Item><Product type=“System.String“>SharePoint 2013</Product><_x0037_9a74352-f26f-4f5e-a1d7-32c39f64ddfa type=“System.Int32″>2</_x0037_9a74352-f26f-4f5e-a1d7-32c39f64ddfa></Item><Item><Product type=“System.String“>Nintex Workflow 2013</Product><_x0037_9a74352-f26f-4f5e-a1d7-32c39f64ddfa type=“System.Int32″>1</_x0037_9a74352-f26f-4f5e-a1d7-32c39f64ddfa></Item><Item><Product type=“System.String“>Nintex Forms 2013</Product><_x0037_9a74352-f26f-4f5e-a1d7-32c39f64ddfa type=“System.Int32″>1</_x0037_9a74352-f26f-4f5e-a1d7-32c39f64ddfa></Item></Items></RepeaterData>

Document template

Before I start with the creation of the workflow, I create a word document named “Order template” in a document library called “Documents”. This document will serve as my template for the “Document Generation” action later on.  

image

Nintex Workflow

As I’ve already mentioned the workflow creates a PDF document with all relevant information concerning the specific order based on the Word template I just described. Every information that is supposed to appear in the document needs to be saved in a variable, so the workflow consists of more than one action.

imageimage

First of all I use two “Query XML” actions to get the information about the particular order positions out of the XML in the column „OrderedProductsandQuantity”. The products are stored in a collection variable called “ProductsCollection” and the quantities are stored in a collection variable called “ProductsQuantityCollection”. This is how the configuration of the action looks like for the gathering of the quantities.

image

Then I create three variables: OrderNumber (Current Item:ID), Requester (Current Item:Created By) and OrderDate (Current Item:Created). Afterwards I use a “For Each” action to iterate through all elements in the collections variables.

 

image

With the help of the “For each” action I get all the products of the order. As I also need the corresponding quantity for the particular product I use the “Get Item from Collection” action.

image

So for each loop I get two values, the product and the corresponding quantity. These two values will temporarily be stored in a dictionary variable called “ProductQuantityDictionary” that I create via the “Create Dictionary” action. The dictionary variable has two keys, “Product” and “Quantity” both text by type.

image

The values in the dictionary are added to a new collection variable called “AllProductsQuantityCollection”. Therefore I use the “Add Item To Collection” action.

image

After the last loop I have a collection variable with complex values that includes all products with the corresponding quantity. The content of the collection variable looks like this:

image

After all the desired information has been stored into variables, I start to configure the “Document Generation” action, which in the end looks like this:

image

In the “Template document library” column I define the document library where the template for the generated documents is saved, in my case “Documents”.

In the “Template” column I select the already existing template called “Order template”. You also have the choice to create a new template if you like to, whereby you can choose between an Excel, a PowerPoint and a Word template.

Then I edit the template by clicking on “Edit in Word”. When the template is opened for the initial creation or for changes, the so called “Nintex Document Generation Tagger” panel can be found on the right side.

image

This panel is used to insert the desired variables into the document template. Therefore the cursor has to be placed where the value of the variable should appear, then the desired variable must be selected and added by clicking in “Insert Tag”.

image

For my variable “OrderNumber” the result looks like this:

image

To display the information of a repeating section in the document I have to create a table. In my case I create a table with two columns and two rows. I use the first row as a header and the second row for the necessary tags.

When I then use the “Nintex Document Generation Tagger” again and chose a collection variable, there’s one additional column, a column named “Tag type” with three different parameters (“Start collection table”, “Key” and “Simple”).

In the first step I place the collection variable with the tag type “Start collection table” in the first column of the table. In the same column I place the collection variable with the tag type “Key” and enter “Product” as the key. In the second column I place the collection variable with the tag type “Key” and enter “Quantity” as the key.

imageimage

The result looks like this:

image

The tag type “Start collection table” specifies the start of a collection variable table, a column will be created for each entry in the collection. This is how my final template with all desired variables looks like:

image

As I like to have the order as a PDF document I select “PDF” in the “Output file type” column. Furthermore I have to define, where the generated documents will be stored. In my case they’ll be stored in the document library “Documents”, which I define  in the column “Output document library”.

In the last step I define the “Output file name”, which in my case consists of “Order –“ as the prefix and the ID of the list element as the suffix.

I configure the workflow to start when a new element has been created and this is how the PDF looks like after the workflow has finished successfully.

image

More information about the “Document Generation” capabilities can be found in the official Nintex Help!

If you have any questions please feel free to ask!

Ein Gedanke zu “Nintex for Office 365 – Document generation with repeating section
avatar

  1. Pingback: Nintex | Pearltrees

Schreibe einen Kommentar