Skip to main content

Nintex Community,

When a flexi-task is assigned, what is the best way to extract the task 'approval url' when not using emails? I have a list view prepared with all necessary fields to complete the business process and want the approval url to be part of the export. My solution has been to query the workflow task list but it is messy. There has to be a better way since the information is already within the task. How do I sent the approval url to a list column without having to do this?.

Workflow Developer Steps

Apologies for being 2 years too late but I hope this helps at least one person :) 

 

Of course, in Nintex's infinite wisdom they neglected to give us functionality for this for who knows what reason.

 

I found another solution here: https://community.nintex.com/t5/Nintex-for-SharePoint/How-do-I-capture-the-Workflow-Task-ID/td-p/42150

 

The solution involves waiting a couple minutes to get the wf task id in a concurrent branch. This feels wrong because no matter how unlikely it is to happen, what if the workflow task took longer than the timer to be created? Then your ID's undefined and your URL'll broken until you fix it manually. Also, god forbid your timer service breaks and now this workflow is completely broken too adding to your list of headaches (shout out to microsoft on that one). 

 

Instead, what you can do, is this: 

 

In the workflow task settings in your nintex workflow set the name of your newly created workflow task to be "listName:{Item ID}" so you can easily identify and select your desired workflow task later. 

 

To have a hyperlink directly to this item on your list, either make a JSLink to populate the url field so it's conditionally shown (doesn't provide a url if it's already completed, for example). Or, if you want to show it all the time, just generate it in your workflow. 

 

When you generate your URL, make it like this: 

 

pWorkflowTaskListURL]/AllItems.aspx?FilterField1=title&FilterValue1=listName:{Item ID}

 

(I forget exactly if it's title or name but if it's not title, try name, and if it's not name, just whatever field contains our identifier) 

 

If you're lazy, and fine with just this solution, you're done. You now have a URL on your original list that redirects users to the workflow task list that only displays that item's task. 

 

BUT, if you want to have it somehow redirect to the workflow task completion form to save a click you need a couple more steps. 

 

If you know anything about JSlinks, they essentially iterate through all visible items top to bottom. SO, since we know that this is the only item that is going to be displayed, make a JSLink that redirects to this item's edit form. 

 

So this JSLink doesn't run when you're just looking at the workflow task list normally, update the url to look like this: 

lWorkflowTaskListURL]/AllItems.aspx?FilterField1=title&FilterValue1=listName:{Item ID}&taskRedirect=true

 

In your JSLink, and if you're bad at regex like me, split the url on "AllItems.aspx?". We know our parameters are always going to be the second item in this array since we made the URL ourselves and aren't some chaotic evil piece of trash that likes to make seemingly randomly generated strings as our addresses. 

 

so shorthand would look something like this:

var params = url.split("AllItems.aspx?")u1].split("&");

 

Then iterate through your param variable and do more JS stuff to make an object like this: 

{

FilterField1: title ,

FilterValue1: listName:{Item ID},

taskRedirect: true

 

then check if (params.taskRedirect) {

   ... redirect to item's editForm

}

 

What's nice about this solution is that it gives you some flexibility too. Like, let's say you wanted to dynamically set the redirectURL once they've approved or denied the task. In that case, you can make your URL directing to the workflow task list look like this: 

 

iWorkflowTaskListURL]/AllItems.aspx?FilterField1=title&FilterValue1=listName:{Item ID}&taskRedirect=true&taskCompletionRedirect={redirectURL}

 

and have an object to work with that looks like the following: 

 

{

FilterField1: title ,

FilterValue1: listName:{Item ID},

taskRedirect: true,

taskCompletionRedirect: {redirectURL}

 

Then, when you redirect the user to the editform, you can append the redirectUrl to the end of it. If I remember correctly, redirecting to a specific url is as simple as appending &source={redirectURL} to your address. 

 

Hope this helps!

 

 

 

 

 


Reply