Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: FindTask

require(["esri/tasks/FindTask"], function(FindTask) { /* code goes here */ });

Description

(Added at v1.0)
Search a map service exposed by the ArcGIS Server REST API based on a string value. The search can be conducted on a single field of a single layer, on many fields of a layer, or on many fields of many layers.

Samples

Search for samples that use this class.

Constructors

NameSummary
new FindTask(url, options?)Creates a new FindTask object.

Properties

NameTypeSummary
urlStringURL to the ArcGIS Server REST resource that represents a map service.

Methods

NameReturn typeSummary
execute(findParameters, callback?, errback?)DeferredSends a request to the ArcGIS REST map service resource to perform a search based on the FindParameters specified in the findParameters argument.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
complete
{
  results: <FindResult[]>
}
Fires when the find operation is complete.
error
{
  error: <Error>
}
Fires when an error occurs when executing the task.
Constructor Details

new FindTask(url, options?)

Creates a new FindTask object. A URL is a required parameter.
Parameters:
<String> url Required URL to the ArcGIS Server REST resource that represents a map service. An example is https://www.example.com/argis/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer.
<Object> options Optional Optional parameters. See options list.
options properties:
<String> gdbVersion Optional Specify the geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater
Sample:
require([
  "esri/tasks/FindTask", "esri/tasks/FindParameters", "dojo/dom", ... 
], function(FindTask, FindParameters, dom, ... ) {
  var find = new FindTask("https://www.example.com/argis/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/");
  var params = new FindParameters();
  params.layerIds = [2];
  params.searchFields = ["STATE_NAME","STATE_FIPS"];
  params.searchText = dom.byId("searchText").value;
  find.execute(params, showResults);
  ...
});
Property Details

<String> url

URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use Services Directory.
Method Details

execute(findParameters, callback?, errback?)

Sends a request to the ArcGIS REST map service resource to perform a search based on the FindParameters specified in the findParameters argument. On completion, the onComplete event is fired and the optional callback function is invoked.
Return type: Deferred
Parameters:
<FindParameters> findParameters Required Specifies the layers and fields that are used to search against.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
Sample:
 findTask.execute(findParams, showResults);
Event Details
[ On Style Events | Connect Style Event ]

complete

Fires when the find operation is complete. The result is an object with a results property containing an array of FindResult. This is the same signature that is returned if the optional callback were specified. Should be used in favor of onComplete (Added at v3.5)
Event Object Properties:
<FindResult[]> results Provides information about a "find result".
See also: execute()

error

Fires when an error occurs when executing the task. (Added at v3.6)
Event Object Properties:
<Error> error ArcGIS Server error message returned in a JavaScript error object.
See also: execute()
Show Modal