Nintex attachment workflow
-
Upload
alan-richards -
Category
Technology
-
view
345 -
download
2
description
Transcript of Nintex attachment workflow
Attachment Workflow Using Office 365 & Nintex
Alan Richards
Table of Contents Introduction ............................................................................................................................................ 2
Scenario ................................................................................................................................................... 3
Problem ............................................................................................................................................... 3
Solution ............................................................................................................................................... 3
Web Service (REST) ................................................................................................................................. 4
Building the Solution ............................................................................................................................... 5
Variables ............................................................................................................................................. 5
Build Dictionary ................................................................................................................................... 6
Call HTTP Web Service ........................................................................................................................ 8
Get an Item from a Dictionary ............................................................................................................ 9
Count Items in a Dictionary .............................................................................................................. 10
Set Workflow Variable ...................................................................................................................... 11
Extract Attachments ......................................................................................................................... 12
Log History ........................................................................................................................................ 15
Final Solution ........................................................................................................................................ 16
Figure 1 - Nintex Workflow Ribbon ......................................................................................................... 5
Figure 2 - Workflow Variables ................................................................................................................. 5
Figure 3 - Actions Pane ........................................................................................................................... 6
Figure 4 - Build Request Headers Dictionary .......................................................................................... 7
Figure 5 - Call HTTP Web Service ............................................................................................................ 8
Figure 6 - Run d/Results to get item from a dictionary .......................................................................... 9
Figure 7 - Count items in a Dictionary ................................................................................................... 10
Figure 8 - Set Workflow Variable .......................................................................................................... 11
Figure 9 - Loop Count ............................................................................................................................ 12
Figure 10 - Get an item from a dictionary (Attachment URL) ............................................................... 13
Figure 11 - Get an item from a dictionary (Attachment Filename) ...................................................... 13
Figure 12 - Upload File .......................................................................................................................... 14
Figure 13 - Calculate loop value ............................................................................................................ 14
Figure 14 - Set temp loop count value .................................................................................................. 15
Figure 15 - Workflow Settings ............................................................................................................... 16
Introduction
This eBook has been written to detail the steps to create a Nintex workflow that will extract attachments from a list item and then upload those attachments to a document library within the same site collection.
The solution is built using SharePoint online in Office 365 and Nintex workflow for Office 365. However the same principles and methods can be used for onPremises SharePoint and Nintex.
Scenario
For this post the scenario is an application form for an organisation that requires applicants to complete a simple online form as shown below and upload their resume and a covering letter
Problem
The above works fine until you have more vacancies and applicants and the only way to get to all the documents is through the submitted forms, what really needs to happen is that the documents are taken from the forms and submitted to a document library where they are sorted by vacancy
Solution
This solution uses Nintex workflow, the reason for this is that InfoPath is slowly being removed from the suite of tools available to a user and Nintex allows you to carry out the types of complex operations that this workflow is going to need
Web Service (REST)
In Office 365 & onPremises SharePoint for that matter, you can access certain information by using a call to a REST web service, for this solution I use the REST service to return the details of the file attachment to a workflow and then use the Nintex upload file routine to take the file and upload it to a document library while creating folders based on the vacancy the applicant is applying for
Building the Solution
Variables
First let’s construct the call to the web service, in Nintex the variables required by the web service are stored in a dictionary, to create a variable open up Nintex workflow for the list and select variables from the ribbon as shown in Figure 1
Figure 1 - Nintex Workflow Ribbon
You will need to create multiple variables for this workflow as shown in Figure 2
Figure 2 - Workflow Variables
Build Dictionary
Now we need to build the dictionary to store the REST Request Headers
From the Actions pane, shown in Figure 3, select Operations | Build Dictionary
Figure 3 - Actions Pane
Drag the action onto the main canvas and click on the white down triangle and select Configure
On the configure screen I need to add the headers that will be sent to the Office 365 web service to gain access to all the details I need. I need two items within the dictionary; Content-type & Accept, the details are shown in Figure 4
Figure 4 - Build Request Headers Dictionary
Call HTTP Web Service
I now need to call the web service, to do this drag the Call HTTP Web Service actions from the integration sub section onto the canvas as shown below and configure the action as shown in Figure 5
Figure 5 - Call HTTP Web Service
So what does the first line of this call do, it basically uses a context variable at the start to call the web service at the current site collection, looks for the ApplicantList list, gets the item that matches the current ID of the list item that launched the workflow and then finds all of the attachments for that list item
Get an Item from a Dictionary
The next step is to get items from the response of the call to the web service.
For this I need to add the Get an Item from a Dictionary action from the Operations action pane and add it to the workflow timeline
Configuration of this item will use a command d/results which will get the data from the web service and then add it to a variable that will be used later. The configuration of this item is shown in Figure 6
Figure 6 - Run d/Results to get item from a dictionary
Count Items in a Dictionary I now need to count the items in the dictionary, this ensure that the
workflow knows how many attachments there are, there wouldn’t be
much point in extracting a single attachment when there are in actual fact
multiple attachments
To do this select the Count items in a Dictionary from the Operations
actions and add it to the workflow timeline
Configuration for this item is shown in Figure 7
Figure 7 - Count items in a Dictionary
Set Workflow Variable As the workflow progresses it is going to use a variable called LoopCount to work
out how many times it needs to run a section of the workflow to ensure if there
are multiple attachments they are all extracted
For this drag the Set Workflow Variable action from the Operations action pane
onto the workflow timeline and configure it as shown in Figure 8
Figure 8 - Set Workflow Variable
Extract Attachments
The next stage of the workflow is to extract the attachments from the list item. To achieve this the part of the workflow that extracts the attachment needs to loop for the amount of attachments that are in the list item.
To start with drag the Loop N Times from the Logic and Flow action pane onto you workflow, the settings for the loop element are shown in Figure 9
Then add the actions shown on the left inside the loop element.
The settings for each element inside the loop are shown in Figures 10 – 14
Figure 9 - Loop Count
Figure 10 - Get an item from a dictionary (Attachment URL)
Figure 11 - Get an item from a dictionary (Attachment Filename)
Figure 12 - Upload File
Figure 13 - Calculate loop value
Figure 14 - Set temp loop count value
What the above does is:
Finds the URL of the attachment
Find the attachment filename
Uploads the file to required location
Sets the temp loop count variable
Sets the loop count variable to the value of the temp loop count variable
What all this does is loops through the upload process based on the number of attachments in the
list item.
Log History The final step is to log the action of the workflow to the history list. Drag the Log to History List from
the Operations action pane and set it to whatever you want to log.
Final Solution
Your final workflow should look like the example on the left.
All you need to do is assign it to the required list and set it to automatic of manual
launch behaviour, which can be found in the settings page.
Figure 15 - Workflow Settings