I am having issues getting a geoprocessing service to run. The service is a simple Python script that converts a table to CSV file. It runs fine in ArcMap. I can publish the service with the input as a constant and get it to run from Javascript. The problem is when I try to run the service with Feature Set created from a Feature Layer in Javascript. I can not get this to work!
My geoprocessing service is here.
function exportAll(){
var query = new esri.tasks.Query();
query.where = "1 = 1";
query.outFields = ["*"];
//parcelsFS is my Feature Service Layer
parcelsFS.queryFeatures(query, function (features) {
var inputFeatures = new esri.tasks.FeatureSet();
inputFeatures = features.features;
var params= { "Table_Name":inputFeatures};
gpTask.submitJob(params, completeCallback , statusCallback,function(error){
//alert(error);
//esri.hide(loading);
});
});
}
function completeCallback(jobInfo){
if(jobInfo.jobStatus !== "esriJobFailed"){
gpTask.getResultData(jobInfo.jobId,"Output_CSV", downloadFile);
}
}
function statusCallback(jobInfo) {
var status = jobInfo.jobStatus;
if(status === "esriJobFailed"){
alert(status);
//esri.hide(loading);
}
else if (status === "esriJobSucceeded"){
//esri.hide(loading);
}
}
function downloadFile(outputFile){
map.graphics.clear();
var theurl = outputFile.value.url;
console.log(theurl);
window.location = theurl;
}
Best Answer
What are the properties of features.features when you do this?
I'm pretty sure that your input features have to have a field list that matches the expected fields that you see when you inspect the 'submitJob' operation of your GP service.
For example, you have:
I've run into a similar problem, and I add another line like so:
To make this:
...where gpInputFields in your case would be this:
..snip
I copied/pasted that list from the first textfield here: http://arcgis-tamarackags101-235134627.us-west-2.elb.amazonaws.com/arcgis/rest/services/Emerson/TableToCSV_FS3/GPServer/TableToCSV/submitJob
That's but one of many, many problems that can arise with consuming GP Services from the JavaScript API. It's helpful while in development to turn in info messages for your service so it reports errors or status back to the console while the service is running.
Here's a link on how to do that: http://resources.arcgis.com/en/help/main/10.1/index.html#//005700000080000000
You can use Chrome debugging tools to view the response from the task as it is executing. Post the GP messages here if you keep having trouble.