I'm running a GP task through the Leaflet-Esri API which returns polygon geometries. I then union these geometries with the standard ArcGIS Server Geometry utilities through a L.esri.request process and the union result must then be used in a final Leaflet GP task process, which is asynchronous and using CORS to force a POST request. The problem is that the final GP Task call does not "detect" the task result (a URL string to a JSON file), even though I can see it being returned in the browser XHR requests and the result is in the ArcGIS Server GP jobs folder. The one issue that I've picked up is that after the Union task, the callback ID for the last GP task does not increment again and I suspect that the Leaflet API is trying to fetch some of the previous GP tasks' results. Is there a way to "reset" the callback ID for the GP task results to ensure that the API is trying to fetch the correct GP task results.
Here is the code for the final GP task call:
var gpServiceTest = L.esri.GP.service({
url: myGPserviceURL,
path: "submitJob",
async:true,
asyncInterval:5,
useCors:true
});
var gpTaskTest = gpServiceTest.createTask();
gpTaskTest.setParam("Input_Polygon_String", rings);
gpTaskTest.setOutputParam('JSON_Features');
gpTaskTest.run(function(error, response, raw) {
loadjson(response.JSON_Features.url);
});
I've found that when I take the polygon results from the Union task and run the final GP task as an isolated function with it before any of the other initial GP tasks, there is no callback function ID added to the task results request. However if I run the final GP task after the initial GP task and Union, a callback function ID, similar to a previous GP task result request callback ID, is added to the result request and that is when the response from the final GP task results give an error.