How to delete one workflow context running on a record through Business rule

Community Alums
Not applicable

Hi All

I have callback date functionality recently developed where in if a ticket is in pending status, callback date is mandatory and when the callback date is elapsed, the system will automatically change the status from pending to Work in progress. This is achieved through a workflow

In case the callback date is changed by the resolver, a business rule will be triggered which will delete the old workflow context (which contains the old callback date) and a new workflow is created for this record.

The issue I am facing is that this record also has an approval workflow running and when I use workflow.deleteWorkflow(current) in the business rule, it deletes both the workflows, causing the approval flow to be triggered again.

Is there a way to delete a single workflow context of a record? I have tried using gliderecording the workflow context table and deleteWorkflow(gr) but it does not seem to work.

I would like to delete the old callback date workflow when the callback date in the ticket changes without touching the approval workflow. Is there a way to achieve this?

Any leads is appreciated.

Thank you

1 ACCEPTED SOLUTION

Community Alums
Not applicable

I got it to work thanks to Servicenow Guru.

I was able to cancel a specific the workflow context

https://www.servicenowguru.com/scripting/business-rules-scripting/canceling-executing-workflows-task-closure/

View solution in original post

2 REPLIES 2

ScienceSoft
Tera Guru

It seems that your approvals are generated via Workflow and therefore if you delete context - you delete both approvals and possibly even tasks. If you try building approvals outside of Workflow - this may be you solution. But keep in mid - it would be more complex.

Or as alternative - use reset Workflow instead of delete

Community Alums
Not applicable

I got it to work thanks to Servicenow Guru.

I was able to cancel a specific the workflow context

https://www.servicenowguru.com/scripting/business-rules-scripting/canceling-executing-workflows-task-closure/