return status of GP call

1516
14
Jump to solution
04-03-2020 11:34 AM
jaykapalczynski
Frequent Contributor

I cant seem to get the results of my GP call....is Synchronous call so .execute would be used.

What am I missing here?

I think I have to use the getResultData because of the Synchronous service

additionally I have an output parameter on the service...I would like to learn how to caputure this value as well

Noting that this works fine:

gpJSON.execute(params);

var HistoricUser = document.getElementById(JSONstring).value;

var params = {
      request: HistoricUser               
};

gpJSON.execute(params).then(function (jobInfo) {
                    
    var jobid = jobInfo.jobId;

    var requestOptions = {
         interval: 500,
         statusCallback: function (j) {
            console.log("Job Status: ", j.jobStatus);
         }
    };

    gpJSON.getResultData(jobId, resultName, requestOptions).then(function () {
         alert("job completed");
    });            
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
14 Replies
jaykapalczynski
Frequent Contributor

Im really puzzled...if I execute and pass the parameter as such above it works and my python script creates a polygon from the passed parameter....BUT I dont get anything back....well I get the below back but cant grab it

If I run right from the service I get this... the big comma delimited "Value" returned below are the IDs of the multi part polygon that is created that I pass back in an output parameter called "result"

I want to return the status AND the below returned parameters and write them to a variable...

Dont know why I cant get them back....I mean the code above in my last post does not even fire a general alert?

0 Kudos
jaykapalczynski
Frequent Contributor

ok so I striped down all the code to a simple .net solution.  Might make what I am trying to do more clear..

Important files: demo.aspx and the JS folder index.js

1. I have a textbox with and example of the string that I am passing to the GP Service

2. I have a button that when clicked calls the JS code and passes a string variable to the GP tool , the same as in the textbox above

3. I am then simply trying to alert the status of the request and eventually the "value" that the GP Service is returning 

....so write status to textbox or something updating every second or so....or just an alert would do

....result of the "Value" returned from the GP Service to a textbox or something....even an alert

I cannot even get an alert to fire inside the gpJSON.execute

Please see attached .zip file with the striped down .net app

0 Kudos
jaykapalczynski
Frequent Contributor

Please see my last couple post....as for debugger....not really sure what I am looking for...

I do see this ???

0 Kudos
by Anonymous User
Not applicable

Hi jay kapalczynski‌,

Well I just have a look your code.

The problem is the asp.net button postback make your form to fully reload and the gptask code is working well.

I add sample with normal html client button vs asp.net button.

And need to adjust the param call as well.

asp.net button click does not make quite noticeable on postback to reload but you can catch by date time log.

Once gptask is executed, form is reload so all the context lost and task will not execute.

Whereas client side button work smoothly.

Please take a look at the sample.

For asp.net web form, I shall suggest to use ajax manager to prevent postback, and disable postback form validation and so on.

You need to check a lot of factor.

jaykapalczynski
Frequent Contributor

THANK YOU very much Than....I really think the main issue was the button itself and it being within the Form....I totally missed the postback and form reload from the button click

CHEERS

0 Kudos