Hide Table of Contents
Supplying parameters for the Geoprocessor

The parameters list in the Services Directory shows the required inputs and outputs of any geoprocessing task. You need to supply all the parameters whose Direction is esriGPParameterDirectionInput and whose Parameter Type is esriGPParameterTypeRequired. You do not have to supply the output parameters because the output is always returned to the callback function as an array of ParameterValue.

You can set up the parameters using JavaScript object notation (JSON), like the following:

var params = { "Input_Observation_Point":featureSet, "Viewshed_Distance":vsDistance };

Be sure to use the same parameter name and order that appears in the Services Directory.

An important challenge you have as a developer is understanding how to construct the required parameters for your model. The chart below shows what you need to create for each type of parameter. Notice that some parameters are represented by primitive JavaScript data types, such as string and number, and some are represented by objects from the ArcGIS JavaScript API, such as FeatureSet and RasterData.

Parameter type Corresponding JavaScript object
GPBoolean boolean
GPDataFile DataFile
GPDate Date
GPDouble number
GPFeatureRecordSetLayer FeatureSet
GPLinearUnit LinearUnit
GPLong number
GPRasterData RasterData
GPRasterLayer RasterData
GPRecordSet FeatureSet
GPString string

String parameters may require that you do some research to understand the syntax the model expects from the string. The Geoprocessing Tool Reference in the ArcGIS Desktop Help is your best resource for understanding how to construct string parameters for tools. Most tools have a command line example that can give you a pretty good idea of how your string parameter needs to look.

Another tactic for finding out string syntax is to add the geoprocessing service to ArcToolbox and run the model from there. Examine the detailed messages that appear and you'll see how the parameters are structured. For example, you might see a message like:

Executing (IDW): Idw C:\Data\spot_elev.shp ELEVATION %SCRATCHWORKSPACE%\Idw_hamilton1 45.76818 2 "VARIABLE 6 500" #

This message appears when you run the IDW tool. If you were having trouble understanding how to construct the search radius parameter, a string, you could learn from this message that it is structured "VARIABLE 6 500". In other words, the search type, number of points, and maximum distance appear in that order, separated by spaces. The Geoprocessing Tool Reference would also tell you this.

A final note about parameters: If you're submitting a FeatureSet with a lot of features or complex geometry, you should reference a proxy page in your code in case your request exceeds the 2000 character limit on GET requests imposed by some Web browsers. See Using the proxy page to learn more.