cancel workflow from flow or using Business rule

sarasaamani
Tera Contributor

i'm not sure how to create run script activity in flow , need some guidance on this

 

alternatively, I tried with after Business rule with script as below, it's just setting flow context to cancel and i still can view the workflow from show workflow option. How do i remove the workflow completely?

 

 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);
      }
1 ACCEPTED SOLUTION

@sarasaamani 

that Related link is not visible to all

what's the point in this requirement if the workflow is already cancelled via your script

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

vermaamit16
Kilo Patron

Hi @sarasaamani 

 

Even if a workflow execution is cancelled, the workflow context for the same will be available. Could you please elaborate a bit on your requirement ? Do you want to abort the workflow execution ?

 

Thanks and Regards

Amit Verma

Thanks and Regards
Amit Verma

Hi @vermaamit16 ritm is set to cancelled and workflow context state is also cancelled, when i click on show workflow i still can see the workflow of that ritm stuck at task activity. i want to either end the workflow or make it not visible. Can i do it from flow? 

Ankur Bawiskar
Tera Patron

@sarasaamani 

If the workflow is cancelled let that UI action be shown. It seems OOB behavior.

what happens when you click Show workflow and if the workflow is cancelled?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ritm is set to cancelled and workflow context state is also cancelled (i believe this is done by after business rule that i created), when i click on "show workflow" from related list, i still can see the workflow of that ritm stuck at task activity. i want to either end the workflow or make it not visible. Can i do it from flow?