TomaszPoszytek
Automation Master
Automation Master

Re: Can You Cancel a Pending Workflow Task?

I don't understand what you want to achieve. Is the "Cancel" one of the options to complete a task?

Or is it just the button that user clicks when they don't want to perform any action?

0 Kudos
Reply
kunalpatel
Automation Master
Automation Master

Re: Can You Cancel a Pending Workflow Task?

@kelliganp ....well since you want to perform some other logic in your primary workflow, what if you create a seperate workflow just to assign the flexi task? Start this workflow from primary workflow but wait till flexi task w/f is completed. Now if you stop the flexi task workflow then it will cancel the flexi task and your primary workflow will proceed further. You can also send and receive variable information between primary and flexi task workflow. Use that to build logic to process when flexi task is canceled. 

0 Kudos
Reply
kelliganp
Workflow Hero

Re: Can You Cancel a Pending Workflow Task?

Hi @TomaszPoszytek,

Thanks for responding. The objective is to have a process that many can cancel even when only a few have an active task. There are several approval tiers in the process and for an expensive item where special, lengthy, approval routing needs to take place, the process could take several weeks or even months to close.

While one of these flexi tasks are running, suppose the requestor decides he wants to cancel the request... He should be able to open the form, select a cancellation panel, sign and confirm. When this happens, I want to know if there is some creative way, without having addidional separate workflows running, to escape/abort any active flexitask. 

I was thinking a parralel branch might do it as @kunalpatel has suggested earlier but the flexi task does not have an "Action ID" variable like some of the other tasks. I also do not want to abandon the use of a flexitask if possible.

Does that clarify? If not let me know what is unclear and I will try and elaborate more.

 

Thanks and regards,

Patrick

0 Kudos
Reply
kelliganp
Workflow Hero

Re: Can You Cancel a Pending Workflow Task?

Hi @kunalpatel,

Good thinking... That is similar to my current solution that I have been using for nearly ten years. I have 2 workflows. One is the primary work horse and the other (abort workflow) sits and listens for the cancellation field to change. If it is cancelled, the abort kills the main workflow, restarts it and runs the cancellation branch of the main workflow's state machine. I want to do this with a single workflow as I may have dozens of extra workflows running. I am looking for a more economical and elegant way of making this happen.

Thanks and Regards,

Patrick

0 Kudos
Reply
TomaszPoszytek
Automation Master
Automation Master

Re: Can You Cancel a Pending Workflow Task?

Hi,

 

so what you can do is to use for example that approach with parallel branch, but in the second branch to flexi task use query task list action. I am doing this by adding related item ID to the title, so then I can query tasks list for tasks having ID in title. It's not very pretty but it works.

 

The other solution would be, to use web service action to call SharePoint API, to get all tasks, along with the field "RelatedItems". That field is an array, so first you would need to go through all the items to extract related item ID, and this way to get a list of really related items 😛

 

Ex.:

 

<d:RelatedItems>[{"ItemId":206,"WebId":"4852a749-124d-43db-9537-7211335849ff","ListId":"908133d7-6bf2-4361-b2e5-ae9553a8e07d"}]</d:RelatedItems>

 Achieve it using this URL:
{YOUR SITE URL}/_api/lists/getByTitle('Workflow%20Tasks')/items()?$select=Id,RelatedItems

 

Regards,

Tomasz

 

Reply
cassymfreeman
Automation Master
Automation Master

Re: Can You Cancel a Pending Workflow Task?

Reply
TomaszPoszytek
Automation Master
Automation Master

Re: Can You Cancel a Pending Workflow Task?

Looks promising. How would you use it?

0 Kudos
Reply
TomaszPoszytek
Automation Master
Automation Master

Re: Can You Cancel a Pending Workflow Task?

Reply
kelliganp
Workflow Hero

Re: Can You Cancel a Pending Workflow Task?

Hi@TomaszPoszytek, I am going to try to model the parallel branch solution first. Then try the solution @cassymfreeman offered.

 

Instead of making the title modification, would it so the same thing to use the flexi task's "Store task IDs" feature and run the query list action in the parallel branch by filtering on the list item id from the flexi task variable? If so, what do I need to do to the task list item to make the flexi task abort?

 

Thanks and Regards,

Patrick

Reply
kelliganp
Workflow Hero

Re: Can You Cancel a Pending Workflow Task?

Hi @cassymfreeman,

 

I am looking at the updated version of the link you posted. Even if the other method described by @TomaszPoszytek is viable, I want to make this process work in principle because it looks like a very useful skill to have. Some questions...

  • Can you tell me how you would apply this?
  • I think I understand the XML and most of the warnings but should I use a web request or a call web service?
  • Will this be a series of actions on a parallel branch as well?
  • I want to escape the flexi task without approving or rejecting per se... should I use the "Other" branch from the flexi task Advanced Options; and if so, do I need to specify "Other" in <nin:outcome></nin:outcome> or can I put in a more meaningful outcome?
  • The help file states "The approver of the task response is determined by the credentials of the user context specified when this method is invoked. If the credentials of the current user context do not match any of the assignees specified by the Flexi task action that created the task item, this method returns ProcessTaskResponseResult.InvalidUser and the task is not updated". What do you think about finding a way to delegate the task to the workflow initiator to overcome that?

 

I hope I did not overwhelm you with questions.

 

Thanks and Regards,

Patrick

 

0 Kudos
Reply