Select to view content in your preferred language

jobID returned as undefined

1502
7
Jump to solution
09-14-2012 04:29 AM
ChadHawkins
Deactivated User
Hi all,

I'm running into an issue retrieving the jobID of an asynchronous geoprocessing job. I am able to retrieve the jobStatus but the jobID is returned as undefined. I am using Internet Explorer 9 (due to interaction elsewhere in the code with ActiveX) and Server 10.0.0.0. As you can see below, the API is being hosted on my server because eventually the application will run on a server with no Internet connection, but the result is the same with the ESRI-hosted API. The relevant portions of the code are below:

<script type="text/javascript" src="http://server/arcgis_js_api/library/3.1/jsapi/"></script> <script language="javascript">  function geoprocessing(){         // returns an array of well-known text values;  var polyArray = retrieveValues();  var gpurl = "http://server/ArcGIS/rest/services/ls_geoproc/GPServer/Landscan";  gp = new esri.tasks.Geoprocessor(gpurl);  var params = { "WKT":polyArray };   gp.submitJob(params, completeCallback, statusCallback); }  function statusCallback(jobInfo){  console.log(jobInfo.jobStatus); }  function completeCallback(jobInfo){  console.log(jobInfo.jobID);  console.log(jobinfo.jobStatus); }


Here are the print statements from the console log:

LOG: esriJobSubmitted  LOG: esriJobExecuting  LOG: esriJobSucceeded  LOG: undefined  [object Error]  [object Error] 


The job does in fact succeed (not sure why the object errors are occuring, could be related somehow?). Does anything look amiss in my code?

Any help is greatly appreciated.
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Deactivated User
According to the documentation the property is jobId not jobID - JS is case-sensitive so this explains the undefined on some of those lines 🙂

Are you able to look at the traffic?  IE9 has a Network tab in the developer tools, just remember to click start before submitting the task.

Also are you able to put a breakpoint in your code, IE should break on a debugger statement provided you haven't got debugged disabled in your Internet Options>Advanced settings.

Just a hunch...I wonder if trying to access an undefined property (due to incorrect case) in your completeCallback causes an error to bubble/overwrite the actual callback arguments etc. would have to run through the source to check...which I don't have time to do!  (let's see what happens when you've corrected the property name, I bet it's this simple)

View solution in original post

0 Kudos
7 Replies
__Rich_
Deactivated User
Wonder if additionally passing an error callback would reveal more information?  Alternatively stick a breakpoint into your completeCallback and have a look at what's in the jobInfo argument.

Suspect that what's being passed into your completeCallback method is not an object of type JobInfo more likely it's an Error.  (that's what the lines from your console output suggest anyway)

Either way, I'd check it.

Additionally you could also look at the traffic to and from the server and look at the 'raw' responses.
0 Kudos
ChadHawkins
Deactivated User
Thanks for the reply. I made the following changes:

function geoprocessing(){
 var polyArray = retrieveValues();
 var gpurl = "http://server/ArcGIS/rest/services/ls_geoproc/GPServer/Landscan";
 gp = new esri.tasks.Geoprocessor(gpurl);
 var params = { "WKT":polyArray };

 gp.submitJob(params, completeCallback, statusCallback, errorCallback);
}

function statusCallback(jobInfo){
        // try to print the jobID here as well;
 console.log(jobInfo.jobID);
 console.log(jobInfo.jobStatus);
}

function completeCallback(jobInfo){
 console.log(jobInfo.jobID);
 console.log(jobinfo.jobStatus);
}

function errorCallback(error){
 console.log(error.name);
 console.log(error.message);
}


And these print statements were in the console log:

LOG: undefined 
LOG: esriJobSubmitted 
LOG: undefined 
LOG: esriJobExecuting 
LOG: undefined 
LOG: esriJobSucceeded 
LOG: undefined 
[object Error] 
[object Error] 


So the jobID appears to always be undefined. Also, I believe my error function is correct but I'm not sure.
0 Kudos
__Rich_
Deactivated User
According to the documentation the property is jobId not jobID - JS is case-sensitive so this explains the undefined on some of those lines 🙂

Are you able to look at the traffic?  IE9 has a Network tab in the developer tools, just remember to click start before submitting the task.

Also are you able to put a breakpoint in your code, IE should break on a debugger statement provided you haven't got debugged disabled in your Internet Options>Advanced settings.

Just a hunch...I wonder if trying to access an undefined property (due to incorrect case) in your completeCallback causes an error to bubble/overwrite the actual callback arguments etc. would have to run through the source to check...which I don't have time to do!  (let's see what happens when you've corrected the property name, I bet it's this simple)
0 Kudos
ChadHawkins
Deactivated User
According to the documentation the property is jobId not jobID - JS is case-sensitive so this explains the undefined on some of those lines 🙂


D'oh! It was staring right at me and I managed to overlook it, I guess that happens when you stare at something for too long. That did the trick, I will work on debugging the [object Error] at the end.

EDIT:
Correcting the property did not affect the [object Error]. I have attached the network log resulting from the job submittal in case that offers any insights.
0 Kudos
__Rich_
Deactivated User
D'oh! It was staring right at me and I managed to overlook it

Me too! 🙂

I have attached the network log resulting from the job submittal in case that offers any insights.

It's the response content that would probably yield more answers - select the entry of interest (probably the last one) and then go to the "Detail View" - either double-click the entry or click the button.

I'd still go for whacking a breakpoint in your code anyway, literally:

function completeCallback(jobInfo){
    debugger; //Poor man's breakpoint ;-)
}
0 Kudos
ChadHawkins
Deactivated User
I figured out the issue. In the completeCallback function I had "jobinfo" instead of "jobInfo" which was generating the error. I thought I had seen "jobinfo" in some samples, and thus had tried testing first one and then the other capitalization but evidently missed this one when changing around. Thanks Rich for your help, much appreciated!
0 Kudos
__Rich_
Deactivated User
I figured out the issue. In the completeCallback function I had "jobinfo" instead of "jobInfo" which was generating the error. I thought I had seen "jobinfo" in some samples, and thus had tried testing first one and then the other capitalization but evidently missed this one when changing around. Thanks Rich for your help, much appreciated!

Double d'oh!

Yep, missed that one:

function completeCallback(jobInfo){
 console.log(jobInfo.jobID);
 console.log(jobinfo.jobStatus);
}


1 out of 2 - damn, I must be slipping...
0 Kudos