Application Framework Reference

Splunk API

cancel()

The cancel() method cancels the current job, if it has not already been canceled. If the job is successfully canceled, the job SID is set to null.

Calling this method raises the jobCanceled and jobStatusChanged events.

Synopsis

status = cancel( onSuccess , onFailure )

Parameters

onSuccess

Function

(Optional) Function to be called on successful cancellation.

onFailure

Function

(Optional) Function to be called on unsuccessful cancellation.

Return Value

Boolean

Cancel request status:

Undefined = Job canceled.

False = Job already canceled or could not be canceled.

Throws

  Error: "Cannot call the job endpoint if we dont have an sid yet"
 

Example

var context = this.getContext();
var search = context.get('search');

if (search.job.cancel(function() {
         console.log('Handle successful job cancellation.');
      }, function() {
         console.log('Handle failure to cancel job.');
      }) == false)
   console.log('job already canceled or could not be canceled.');
 

See Also

setAsAutoCancellable()
canBeAutoCancelled()
Splunk.Search.abandonJob()