Solved

Trying to implement Get Tasks action


Badge +5

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.

icon

Best answer by Gavin-Adams 2 June 2021, 00:44

View original

10 replies

Userlevel 4
Badge +12

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.


 



 


 


 


 


 


 


 


 


 


 


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.



 


 


 


 


 


 


 


 


 


 


 


 


 


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


eg from this log action.


 



 

Badge +5

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.

Userlevel 4
Badge +12

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


 

Badge +5
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.
Userlevel 4
Badge +12

@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.

Badge +5
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.
Userlevel 4
Badge +12
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.
Badge +5
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.
Userlevel 4
Badge +12

@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.



 


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.


 


Badge +5
Hi @Gavin-Adams,

Still, I need to know the Task ID of each Assignment. I still need to use Get Tasks action to get that even if I use the Branch by Stage action.

Reply