AnsweredAssumed Answered

Call & pass parameters to GP Service

Question asked by jay.kapalczynski on Mar 31, 2020
Latest reply on Apr 2, 2020 by jay.kapalczynski

I have a python script that works great.

I created a tool in a toolbox and point to the python script and this runs great.

I then run the tool again and publish it to a service.

From the service I add my parameter (see below) and it runs great.

SO far so good.

 

Now from JavaScript I do the following (see below code at bottom). 

But this time it does not accept the parameter it keeps using the default value that was created on the service after I published it. 

To publish the service I am right clicking the result in ArcMap and using that to publish

1. I cannot figure out how to remove the default value

2. I cannot figure out  how to run the tool without adding a parameter before I publish it to ArcGIS Server

3. I cannot figure out how to over write the default value from JavaScript...

 

 

If I copy the string I am trying to use in Javascript and paste it in the GPService in ArcGIS Server it runs FINE.

BUT using the same string and calling the SAME ArcGIS Service from JavaScript it uses the default value that was created when it was published to ArcGIS Server.

 

I  can copy the below string DIRECTLY from the code below without the ; at the end and it works fine in the GP Service

 

{"employees": [{ "address": "1520 Split Oak Ln, Henrico, Virginia, 23229", "distance": "10", "id": "1" }, { "address": "113 Buffalo Rd, Clarksville, Virginia(VA), 23927", "distance": "50", "id": "4" }, { "address": "8817 Sherando Dr, Bristow, Virginia(VA), 20136", "distance": "20", "id": "5" }]}

 

Is it the default value?

Is it how I am pushing the parameter to the Service?

Something else?

 

I hope that makes sense.  Thoughts????

var gpUrlJSON = "https://vvvvvv.gov/arcgis/rest/services/Test/GeometryJSON/GPServer/createJSON";

var gpJSON = new Geoprocessor(gpUrlJSON);



// SNIP

var dictstring = {"employees": [{ "address": "1520 Split Oak Ln, Henrico, Virginia, 23229", "distance": "10", "id": "1" }, { "address": "113 Buffalo Rd, Clarksville, Virginia(VA), 23927", "distance": "50", "id": "4" }, { "address": "8817 Sherando Dr, Bristow, Virginia(VA), 20136", "distance": "20", "id": "5" }]};
           
dictstringtoPass = dictstring;

gpJSON.execute(dictstringtoPass);

Outcomes