I have a geoprocessing tool that accepts multiple input parameters, how to pass multiple parameters from javaScript.
var param1 = { "Input_Layer": dijit.byId('spreadmodel1layers').value, "Start_locations": featureSet, "Default_break_values": box0.attr("value") }; var param2 = { "Input_Layer": dijit.byId('spreadmodel2layers').value, "Start_locations": featureSet, "Default_break_values": box1.attr("value") }; var params = []; params.push(param1); params.push(param2); esri.show(loading); gp.submitJob(params, completeCallback, statusCallback, function(error){ alert(error); esri.hide(loading); });
After submitting the job it comes back crying "Esri Job Failed".
I want to know that is it valid way to pass multiple parameters to Asynch GP tool.
Thanks
What happens if you only pass the first parameter in the array? Also make sure that the array-parameter is actually an array and not an JSON object or string.
Sorry for the late reply.
I have changed submit parameters like this:
var param1 = { "Input_Layer": dijit.byId('spreadmodel1layers').value, "Start_locations": featureSet, "Default_break_values": box0.attr("value") }; esri.show(loading); gp.submitJob([param1], completeCallback, statusCallback, function(error){ alert(error); esri.hide(loading); });
But result is pity much same.
I have also tried
var features= []; features.push(f1Graphic); var f1featureSet = new FeatureSet(); var f2featureSet = new FeatureSet(); f1featureSet.features = features; features = []; features.push(f2Graphic); f2featureSet.features = features; var featureSetParam = []; featureSetParam.push({"f1s":f1featureSet,"f2s":f2featureSet}); featureSetParam.push({"f1s":f1featureSet,"f2s":f2featureSet}); gp.submitJob(featureSetParam, completeCallback, statusCallback);
with same result.
According to API docs
<Object > inputParameters | Required | The inputParameters argument specifies the input parameters accepted by the task and their corresponding values. These input parameters are listed in the parameters field of the associated GP Task resource. For example, assume that a GP Task resource has the following input parameters:
{ Input_Points: <FeatureSet>, Distance: <Number> } |
It does not clearly says that inputParameters can be an Array.
Please guide how I can pass any array of params in submitJob function.
Maybe you can test and modify the parameters passed in the http request directly in the GP service directory service page or the GP tool from which it was pubilshed to see that the input parameters are valid.
Do you agree that we can pas an array like this? If yes then I should start
blaming the tool and testing it via REST endpoint. By the way it works all
well in ArcMap. Thanks for the help.
You should be able to pass an array. I don't know anything about your model, but if you say that it works on the Desktop side with the parameters as passed in the http request, then I can't see why it would not work via the REST endpoint. Can you provide the request header information with the parameters values?