Tuesday, July 21, 2015

Opening Nintex Workflow for Office 365 Task Forms in Edit Mode

Note: Since originally posting this blog, I found an easier solution that accomplishes the same outcome. I’ve updated the post to reflect this.

This post addresses another key limitation in Nintex for Office 365: opening your task forms directly in edit mode.

When using the actions “Assign a Task” or “Start a Task Process” a Workflow Tasks list will be created that allows users to approve/reject tasks or other various options.  These task forms have several different views, and two of the main ones are ‘Display’ and ‘Edit’. The most user friendly option is to have the task link open directly to ‘Edit’ view so users do not have to click edit in the top of the ribbon before they can make changes. Unfortunately, the only variable link to the task form in Nintex for Office 365 links you to the ‘Display’ form. So what can we do?

First let’s take a look at the link that Nintex gives us in that task variable. It comes in the format of:

YourSiteCollection/Lists/Workflow%20Tasks/DispForm.aspx?ID=001&Source=YourWorkflowTaskList

For our purposes, we want to edit that URL and replace DispForm.aspx with EditForm.aspx. This is easy enough using the ‘Build String’ action but we run into a problem. How do we get the ID of the task item? We know the ID of our current item that the action is running on however the ID of the task item is not necessarily the same as the ID of our current item since it is located in the Workflow Tasks list.

We need the ID of the current workflow task to build a dynamic string that links to the task in Edit mode. This is where we run into a Catch-22 situation; the task needs to be created before we get an ID, but we need that ID before the task is created to create the link. In this post, I will show you how to get this ID before the task is created and build your string using out-of-the-box Nintex functions and information from our lists.

The first step is to query the Workflow Tasks list to get the largest ID in that list. Drop in a ‘Query List’ action and configure it as follows: 

clip_image002

The key here is to change the “Output type” to use Separate output per column instead of single output. Then simply store that new output in a Number variable and use that for your math calculation.

Now drop in a ‘Do Calculation’ action and configure it as follows:
clip_image004[1]
Your first operand will be the newly created number variable. Then simply set it to add 1 and overwrite your number variable to store the new value.
Now we have the ID value of the next task that will be created. The only thing left to do is create the new URL. Now we can simply use the ‘Build String’ action and configure it as follows:
clip_image006[1]

Looking at our URL from before you will see the adjustments we need to make. Your new string should look like this:
YourSiteCollection/Lists/Workflow%20Tasks/EditForm.aspx?ID={Variable:IDasNumber}&Source=YourRedirectURL

‘Disp’ is replaced with ‘Edit’ and “ID=001” is replaced with “ID=Your New Variable”. As a bonus, the URL after ‘&Source’ can be entered as whatever you would like! This will redirect the user to a page of your choosing after the task has been completed. The default is to go to the “Workflow Tasks”. Store this item in a new variable and you have your link! I called mine “TaskEditURL”

Finally, to use this link go to your “Assign a Task” or “Start a Task Process” action and open the “Task Creation Email Options”. Drop in a hyperlink and point it to your new “TaskEditURL” variable.
clip_image008[1]

Now you’re done! The hyperlink will direct the user to an instantly editable task form!

 

**DISCLAIMER: This only works if the task is assigned to a single person. If the task is assigned to two or more every person will get the same task link and the workflow will fail. If you are lucky enough to have Nintex Forms, there is a very simple workaround using JavaScript that will achieve the same functionality for as many number of people as assigned. You can view that solution here.