Linkin' Tasks or How to Get That Pesky Task Item URL

10 10 10.1K

While Linkin' Tasks could certainly be the name of an amazing new alternative band, I would like to use this post to highlight a scenario that a fair amount of you may have faced while building a workflow:

You assign a task to someone and wanted to get the Task ID or URL associated to the task itself while the task was pending but found out you can't!

This seems to come up often when:

  • People are building with a List Item first approach and want the ability to build the task item URL to embed in the initial form. This is not unlike using a single InfoPath form to drive the data collection and approval process or have users navigating in and out of the initial form often.
  • There is a need to write the task URL to a another list, backend database, or LoB for increased 'findablity'.

Now you may be thinking to yourself, "Just hold on a second... I can just create a variable and store the TaskID in it when I configure my task in the workflow designer! Bam!".   But... and it's a big but... The Task ID value isn't populated until the task is completed.

Curses! Foiled again...

Well, as it turns out, I have a little trick up my sleeve that I would like to share. The magic of Nintex allows me to use things like parallel branching and looping to do other things while my task is pending. So below I will show you how to get the Task ID and URL for a pending task.

Note: Some of the steps below could be further automated (e.g. collecting up the task list ID, removing the link to the task after the task has been completed, etc.) and there is some additional complexity to consider if you're creating individual tasks for many individuals belonging to a group (which can be solved by using collections) but for the sake of this blog post I have inserted some static values (e.g. the task list ID in the first Build String action) and target a single assignee to quickly demonstrate the solution.

The workflow


There isn't too much setup necessary outside of finding the task list ID and possibly adding a Hyperlink column to the list.
The first can be accomplished in a couple of different ways; you could pull it out of the URL when you navigate to the task list (which may not be very friendly as you'll see URL encoding in action), or by opening the site in SharePoint Designer and navigating to the appropriate task list which will display its ID.

Workflow variables


*Make sure your Boolean Found Task variable is set to 'No' so that you can enter the loop!


  1. With the Task List ID, I've chosen to use a Build string action. Keep in mind, since this is a static variable, I could have just simply saved the Task List ID as the default value for the variable but by using a build string action but I wanted to keep the workflow design flexible for when I decide to tool this workflow to automatically collect this metadata:

  2. Next we add a Run parallel actions action so that we can assign our task and keep an eye on it at the same time:

  3. The task assignment is fairly pedestrian but the looping logic is the secret sauce here. We need to add a Loop action and configure it:

  4. Now add a Query list action so that we can query the task list and find the task associated with our running workflow. Notice how I filter the task list results by the Workflow Instance ID and the store the task's ID in my NumTaskID variable. 

    Keep in mind that you could look at Task Lists in other sites by using the CAML editor and inserting the appropriate list GUID:

  5. Now we add a Set a condition action so we can check if a valid task ID was found:

  6. If a task has not yet been assigned we'll just add a Pause for... action and have the workflow wait a minute before the loop queries the task list again. Otherwise, if a valid task was found, we add a Build string action to construct the task list items URL and store that URL into its own variable:
  7.  Now we just want to "flip the bit" so to speak by adding a Set variable action so we can change the Yes/No flag on the Found Task variable to Yes which will allow us to exit the loop:

  8. Lastly, add a Set field value action and configure it to save the URL to the task in the current item.

    Note, you can always pass this along to other systems, etc.:


Item form with the Task URL:

After clicking on the URL, you will navigate directly to the task form for the currently assigned task:


So there you have it. I hope this helps you and as always keep on sharing your experiences here on Nintex Connect!

Note: I will be adding this workflow to the Nintex Xchange as well.