JobInfo

Class: esri/rest/support/JobInfo
Inheritance: JobInfo Accessor
Since: ArcGIS API for JavaScript 4.20

Represents information pertaining to the execution of an asynchronous geoprocessor request on the server.

See also:

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Stringmore details

The name of the class.

more detailsAccessor
Stringmore details

The unique job ID assigned by ArcGIS Server.

more detailsJobInfo
Stringmore details

The job status.

more detailsJobInfo
GPMessage[]more details

An array of messages that include the message type and a description.

more detailsJobInfo
Objectmore details

The options to be used for data requests.

more detailsJobInfo
Stringmore details

ArcGIS Server Rest API endpoint to the resource that receives the geoprocessing request.

more detailsJobInfo

Property Details

declaredClass Stringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

jobId String

The unique job ID assigned by ArcGIS Server.

jobStatus String

The job status.

Possible Values:"job-cancelled"|"job-cancelling"|"job-deleted"|"job-deleting"|"job-timed-out"|"job-executing"|"job-failed"|"job-new"|"job-submitted"|"job-succeeded"|"job-waiting"

messages GPMessage[]

An array of messages that include the message type and a description.

requestOptions Object

The options to be used for data requests. These options can also be controlled through the requestOptions method parameter.

sourceUrl String

ArcGIS Server Rest API endpoint to the resource that receives the geoprocessing request.

Method Overview

Name Return Type Summary Class
Promise<JobInfo>more details

Cancels an asynchronous geoprocessing job.

more detailsJobInfo
Promise<JobInfo>more details

Sends a request for the current state of this job.

more detailsJobInfo
more details

Stop monitoring this job for status updates.

more detailsJobInfo
Promise<ParameterValue>more details

Sends a request to the GP Task to get the task result identified by resultName.

more detailsJobInfo
Promise<ParameterValue>more details

Sends a request to the GP Task to get the task result identified by jobId and resultName as an image.

more detailsJobInfo
Promise<MapImageLayer>more details

Get the task result identified by jobId as an MapImageLayer.

more detailsJobInfo
*more details

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

more detailsJobInfo
Objectmore details

Converts an instance of this class to its ArcGIS portal JSON representation.

more detailsJobInfo
Promise<JobInfo>more details

Resolves when an asynchronous job has completed.

more detailsJobInfo

Method Details

cancelJob(jobId, requestOptions){Promise<JobInfo>}

Cancels an asynchronous geoprocessing job. Requires an ArcGIS Server 10.1 service or greater.

Parameters:
jobId String

A string that uniquely identifies a job on the server. It is created when a job is submitted for execution and later used to check its status and retrieve the results.

requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
Type Description
Promise<JobInfo> When resolved, returns a JobInfo.
checkJobStatus(requestOptions){Promise<JobInfo>}

Sends a request for the current state of this job.

Parameter:
requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
Type Description
Promise<JobInfo> When resolved, returns a JobInfo.
destroy()

Stop monitoring this job for status updates.

// Stop monitoring this job for status updates.
jobInfo.destroy();
See also:
fetchResultData(resultName, gpOptions, requestOptions){Promise<ParameterValue>}

Sends a request to the GP Task to get the task result identified by resultName.

Parameters:
resultName String

The name of the result parameter as defined in Services Directory.

gpOptions GPOptions
optional

Input options for the geoprocessing service return values.

requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
Type Description
Promise<ParameterValue> When resolved, returns an object with a property named result of type ParameterValue, which contains the result parameters and the task execution messages.
fetchResultImage(jobId, resultName, imageParams, requestOptions){Promise<ParameterValue>}

Sends a request to the GP Task to get the task result identified by jobId and resultName as an image.

Parameters:
jobId String

The jobId returned from JobInfo.

resultName String

The name of the result parameter as defined in the Services Directory.

imageParams ImageParameters

Specifies the properties of the result image.

requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
Type Description
Promise<ParameterValue> When resolved, returns an Object with a mapImage property of type MapImage
fetchResultMapImageLayer(jobId){Promise<MapImageLayer>}

Get the task result identified by jobId as an MapImageLayer.

Parameter:
jobId String

The jobId returned from JobInfo.

Returns:
Type Description
Promise<MapImageLayer> A promise resolving to an instance of MapImageLayer.
Example:
// Get the resulting map image layer from a completed geoprocessing job.
jobInfo.fetchResultMapImageLayer(jobInfo.jobId)).then(function(layer){
  view.map.add(layer);
});
fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter:
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns:
Type Description
* Returns a new instance of this class.
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns:
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.
waitForJobCompletion(options){Promise<JobInfo>}

Resolves when an asynchronous job has completed. Optionally job progress can be monitored.

Parameters:
Specification:
options Object
optional

Options. See properties below for object specifications.

Specification:
interval Object
optional
Default Value: 1000

The time in millisecond between remote job status requests.

signal Object
optional

AbortSignal allows for cancelable asynchronous job. If canceled, the promise will be rejected with an error named AbortError.

statusCallback Object
optional

Callback function that is called at the specified interval. Use this method to monitor job status and messages.

Returns:
Type Description
Promise<JobInfo> When resolved, returns a JobInfo.
Example:
// Submit an asynchronous geoprocessing job. Display the remote job status every 1.5 seconds.
// When the job has completed at the output as a MapImageLayer.
const startDate = "1998-01-01 00:00:00";
constendDate = "1998-05-31 00:00:00";
const params = {
  query: "(Date >= date '" + startDate + "' and Date <= date '" + endDate + "')"
};

const url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot";

submitJob(url, params).then((jobInfo) => {
  const jobid = jobInfo.jobId;

  const options = {
    interval: 1500,
    statusCallback: (j) => {
      console.log("Job Status: ", j.jobStatus);
    }
  };

  jobInfo.waitForJobCompletion(options).then(() => {
    const layer = jobInfo.fetchResultMapImageLayer();
    map.add(layer);
  });
});

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.