Select to view content in your preferred language

Is this right way to pass multiple params to Asynch geoprocessing tool?

2666
5
05-24-2016 03:34 AM
omega_cancer
Frequent Contributor

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

0 Kudos
5 Replies
FC_Basson
MVP Regular Contributor

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.

omega_cancer
Frequent Contributor

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

submitJob(inputParameters, callback?, statusCallback?, errback?)

<Object> inputParametersRequiredThe 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:
  • < GPFeatureRecordSetLayer > Input_Points
  • < GPDouble > Distance
The parameters argument for the above inputs is a data object of the form:
 { 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.

0 Kudos
FC_Basson
MVP Regular Contributor

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.

0 Kudos
omega_cancer
Frequent Contributor

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.

0 Kudos
FC_Basson
MVP Regular Contributor

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?

0 Kudos