Application Framework Reference

Splunk API

finalize()

If the current job has not yet finished, the finalize() method stops the job, unpausing the job if it has been paused.

This method raises the jobFinalized and jobStatusChanged events.

Because we cannot predict when job polling will finish it is possible to request a job be paused that, on the server, is actually done. The first time the server indicates a job is paused or finalized, a jobPaused event is triggered. If the job state is also set to done, jobProgress and jobDone events are also triggered.

Synopsis

status = finalize( onSuccess, onFailure )

Parameters

onSuccess

Function

(Optional) Function to be called on successful finalization.

onFailure

Function

(Optional) Function to be called on unsuccessful finalization.

Return Value

Boolean

Job finalization request status:

undefined = Finalize request made to the server.

false = Job has already finished.

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.finalize(function() {
         console.log('Handle successful job finalization.');
      }, function() {
         console.log('Handle failure to finalize job.');
      }) == false)
   console.log('Job has already completed.');
 

See Also

Splunk.Context
Splunk.Search
isDone()
isFinalized()