Workflow - cancelContext(GlideRecord context)

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

Table 1. Parameters
Name Type Description
context GlideRecord GlideRecord of the running context to cancel.
Table 2. Returns
Type Description
void

// 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 gr = new GlideRecord('wf_context');
      
      if (gr.get(current.context)) 
          w.cancelContext(gr);
      }