Cancel WorkFlow

ma kaiyue
Giga Guru

If I have an Approval WorkFlow in execution and I want to make a button to cancel the flow execution, what method can I use?

workflow.cancel() ?

Will it stop other flows as well?

 

Thanks in advance!

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

HI @ma kaiyue here is the sample script in documentation to cancel the workflow

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

Regards
Harish

Sandeep Rajput
Tera Patron
Tera Patron

@ma kaiyue Cancel Workflow method cancels all the workflows attached with a GlideRecord.

 

Workflow - cancel(GlideRecord record)

Cancels all running workflows on this record by broadcasting the cancel event to activities in all running workflows on this record.

 

You may wish to use 

Workflow - cancelContext(GlideRecord context)

Cancels this running context by broadcasting a cancel event to activities in this workflow context

 

For more information please refer to https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...