Skip to main content
Nintex Community Menu Bar

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
 

190689_pastedImage_23.png
 

Setup

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

 

190685_pastedImage_15.png

       

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

 

Steps

 

  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:

    190680_pastedImage_13.png
  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:

    190681_pastedImage_14.png
  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:

    190686_pastedImage_20.png
  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:

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

    190688_pastedImage_22.png
     
  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:
    190690_pastedImage_24.png
  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:

    190691_pastedImage_25.png
     
  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.:

    190692_pastedImage_26.png
     

 

Results

 

Item form with the Task URL:

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

 

 

 

 

Conclusion

 

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.

Better band name than article... JK! This is great Brad, really appreciate it. I will definitely be using this in the future. 


Thanks Bingham Blalock!

I'd love to attach the workflow but Jive is being uncooperative at the moment. I'll update the post as soon as those responsible for this interruption have been sacked.


Hi Brad Orluk‌, thanks for the idea..

do you have any suggestion on how to extend this in case in your workflow you have to find more task ids (e.g. if there are two assign flexi task actions)? In that case, the query filter by workflow instance id is not enough for the second task..


Hey ‌, 

Yes that's right, I eluded to that scenario in my post.  

What I would suggest is simply collecting all of the Task ID's associated with the workflow instance and then using a For Each loop you can iterate through each one of those assigned tasks and capture the details or URL's for each one. Plus, once you've identified those tasks you can decide, based on additional filtering, which ones to roll information up on, etc.


Hi

I've got a problem with that. Everything is set up according to your manual but it's not working. The loop action still running but numTaskID is still null and haven't been found.

Do you know where could be the problem?

Thanks


For some reason (maybe it's a bug in O365) this solution doesn't work for nintex workflow online‌... When it stops on thepause workflow‌ action it never unpauses. Even if it is just a minute. I did it a bit other way round:

  1. Loop until querying a task list returns a collection of task IDs (comparison: Instance Id = {WorkflowContext:Instance ID}) - I record number of returned items - for breaking the loop.
  2. Then I run "Office 365 update permissions" action which is just updating permissions for all tasks from "Workflow Tasks" list meeting this equation: Instance Id = {WorkflowContext:Instance ID}

To me it works like a charm

Regards,

Tomasz


But hey, if you use "instance id" for comparison then in return you will get a collection of taks created in current workflow. The "instance id" is the ID of the workflow, not unique for a task. So that scenario, if works, would return all tasks related data, so that you need only to iterate through it and add your custom logic.

Regards,

Tomasz


It works thx!


Spot on. Plus, in Nintex for Office 365 (due to workflow engine differences) one can simply push the workflow forward without stopped while the task is assigned so the parallel looping logic may not be necessary based on what you're trying to achieve with your tasks.


Thanks Great article. Would this work in nintex for sharepoint 2010 ?

Have a situation where the third step in the notifier/approver chain in a workflow actually is a team and a shared email address. I wanted the notification to be able to go to this group mailbox but any of the individuals checking should be able to approve.

Thanks!

Jennifer


Reply