artmov
Scholar

Trying to implement Get Tasks action

Jump to solution

I have a workflow where I added a Get Tasks action on a parallel path with Assign Task action.  The Get Task action stores the results in an Object data type.  I can access Object.Tasks, but I cannot figure out how to get individual properties of each task.  If I use Get Item from Collection action, that stores the results in a Text type, so then I cannot get to individual properties.

I need to know how to access the ID, Name etc properties of each task.

Regards.

Labels: (1)
0 Kudos
Reply
10 Replies
Gavin-Adams
Explorer

Re: Trying to implement Get Tasks action

Jump to solution

hi @artmov 

you need to do a loop for each after the get tasks.

I have a workflow which does staff surveys. I have another WF which cancels the active tasks after a period of time.

 

wf.png

 

 

 

 

 

 

 

 

 

 

Note that the get tasks action only seems to find the tasks from the last five days unless you add in an earlier date for the query.

get tasks.png

 

 

 

 

 

 

 

 

 

 

 

 

 

Once you are inside the loop for each action you can see the individual task properties.

eg from this log action.

 

loop variables.png

 

View solution in original post

Reply
artmov
Scholar

Re: Trying to implement Get Tasks action

Jump to solution

Hi @Gavin-Adams,

I am new to this forum, so I am still not able to navigate comfortably here.  Thank you very much for your quick reply.  I was amazed how quickly you sent me a solution that I was struggling with for a couple of days already.  First I only saw an email with the partial text of your reply and I jumped to try it, but still was struggling until I returned to the forum and saw your screenshot.  I greatly appreciate the amount of detail you put in.

Regarding your note about the date range, I also noticed that if I use current date as a Start Date, the response object will return empty.  I had to set the Start date to one day prior current date in order to see the latest Assign Tasks.  Do you have a suggestion about how to properly set the date range to get the latest Task?

Best Regards,

Art.

0 Kudos
Reply
Gavin-Adams
Explorer

Re: Trying to implement Get Tasks action

Jump to solution

Thanks Art (@artmov ),

just happened to build a similar WF only a few weeks ago so was easy to grab the details.

 

Regarding the date range, if you are doing the get tasks in parallel you might be able to leave the date fields in the get tasks action blank.

Otherwise you could try putting the workflow content initiation time

 

Reply
artmov
Scholar

Re: Trying to implement Get Tasks action

Jump to solution
Hi @Gavin-Adams,

Thank you for the tip. I did not realized that the date range was optional. I took that out and it is working fine.
One other issue I am facing now is that Date Created is returning as a string and I cannot see how I can select the latest Task from the list. If that was a date, I could have compared the Date Created values. There is no action to convert a string to a date.
Best Regards.
0 Kudos
Reply
Gavin-Adams
Explorer

Re: Trying to implement Get Tasks action

Jump to solution

@artmov 

what is your actual requirement with the parallel action and the get tasks?

(or the overall workflow concept / requirement?)

 

Just wondering if it's a bit more complicated than it needs to be.

0 Kudos
Reply
artmov
Scholar

Re: Trying to implement Get Tasks action

Jump to solution
Hi @Gavin-Adams,
I need to make sure that I am selecting the latest Assigned task from the the collection. If the latest is always on the top, then I don't need to worry about comparing dates.

Regards.
0 Kudos
Reply
Gavin-Adams
Explorer

Re: Trying to implement Get Tasks action

Jump to solution
The assign a task action only creates a single task within that workflow instance. (unless you have the Assign a task action within a for each loop or some other logic action)

Just not understanding why you have multiple tasks.
In the get tasks action if you pass in the workflow instance ID, it will return a collection but there should be only 1 task within that collection.
0 Kudos
Reply
artmov
Scholar

Re: Trying to implement Get Tasks action

Jump to solution
Hi @Gavin-Adams,

Thank you for being so patient. In my workflow I have multiple approval levels. First it goes to the Section Manager, and then it goes to Division Manager. Also, there is a chance that it will be returned to the Section Manager for corrections. At any point I have to get the correct Task. If I knew that the latest Task is always on the top of the collection, meaning that it has Index 0, then I have no worries - just pick up the top Task at any point and you have the correct URL. Just guessing.
That is my workflow.
Best regards.
0 Kudos
Reply
Gavin-Adams
Explorer

Re: Trying to implement Get Tasks action

Jump to solution

@artmov ,

Are you using 'branch by stage'?

(or state machine in the old language)

 

On the assumption that you are not here are my notes on this concept:

 

I think you can avoid the get tasks by using a branch by stage logic.

Based on the outcome of the task you can use the change stage action to move non-sequentially through the workflow.

branch by stage.png

 

You can add a 3rd outcome to the div manager task for corrections and send the workflow back to the section manager to do it again. (would probably add in an email before the change stage on the corrections outcome to let the section mgr know what they have to do)

 

Check out the help file for the action

Also in the learn.nintex.com (Nintex University) check out the course 'Automating Complex Processes - Nintex Workflow Cloud'. It has some training exercises on branch by stage.

 

Check out the youtube video too.

 

0 Kudos
Reply