The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Cancel workflow of a ticket using flow designer

Community Alums
Not applicable

Hi, I want to cancel the workflow of a ticket using the flow designer.

 

currently in business rule using wf.cancel(current), I'm cancelling the workflow, but I am not getting any scripting option or OOB action to cancel the workflow for a ticket.

 

Can some help me with this please?

1 ACCEPTED SOLUTION

Vallabh Baradk2
Giga Guru

Hi @Community Alums ,

 

Could you please try "cancelContext(GlideRecord context)" method.

 

// If a workflow has started for this item, cancel it, where current is a task record with a workflow context
      if ((current.stage == 'Request Cancelled') && current.context 
          && !current.context.nil()) {
      var w = new Workflow();
      var now_GR = new GlideRecord('wf_context');
      
      if (now_GR.get(current.context)) 
          w.cancelContext(now_GR);
      }

Please mark answer as helpful or correct if it works for you.

 

Regards,

Vallabh

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Community Alums 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0750702

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Community Alums
Not applicable

Hi @Dr Atul G- LNG ,

 

I have checkout the KB0750702, but it's about just cancelling the flow when certain criteria are met, but I'm looking for somethings else.

 

I'm looking for a action or run script option to cancel the workflow (Please note I'm talking about legacy workflow and not the flow), using the flow designer.

 

Like currently we can cancel the workflow by using "wf.cancel(current)" in business rule when certain criteria is met. But Im looking whether if we can do that using flow designer only.

Hi @Community Alums 

 

I think there is no OOTB way for this. other than the above link. 

 

We may wait for expert to reply on this.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Vallabh Baradk2
Giga Guru

Hi @Community Alums ,

 

Could you please try "cancelContext(GlideRecord context)" method.

 

// If a workflow has started for this item, cancel it, where current is a task record with a workflow context
      if ((current.stage == 'Request Cancelled') && current.context 
          && !current.context.nil()) {
      var w = new Workflow();
      var now_GR = new GlideRecord('wf_context');
      
      if (now_GR.get(current.context)) 
          w.cancelContext(now_GR);
      }

Please mark answer as helpful or correct if it works for you.

 

Regards,

Vallabh