|
POST
|
I am doing to below from JavaScript API. Passing parameters from Javascript to a GPService in ArcGIS Server Is there a way to do the same from C# in .Net framework? if so how? var gpUrl = "https://xxxxx.gov/arcgis/rest/services/Test/createGeometry/GPServer/Geometry";
var gp = new Geoprocessor(gpUrl);
for (var f = 0; f < text.length; f++) {
obj = JSON.parse(text);
varaddress = obj.employees[f].address;
vardistance = obj.employees[f].distance;
varid = obj.employees[f].id;
var params = {
address: varaddress,
distance: vardistance,
uniqueid: varid
};
gp.execute(params);
}
... View more
03-31-2020
11:28 AM
|
0
|
7
|
3954
|
|
POST
|
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);
... View more
03-31-2020
10:04 AM
|
0
|
2
|
1668
|
|
POST
|
Thanks...for what its worth...not trying to put a check box in a geodatabase field....rather I have a .net form that has a bunch of check boxes on it...right now its feeding a SQL table with a bit field type. This is being brought into SDE which does not have a specified BIT field type...but short integer should work.....this is what I was getting at... When submit is done on the form I would simply check for checked or not and then apply a 0 or 1 to that short integer field....just a bit more code handling...
... View more
03-31-2020
09:14 AM
|
0
|
0
|
2530
|
|
POST
|
I have a table that was put together in SQL Server with a bunch of BIT field types... I am not bring that into SDE Although when you create a table in SDE there is no BIT field data type....only short integer.... How is this dealt with....I basically want a form that will have a check box...the field behind will either be checked or not checked.... how do I lay this out? ideas / thoughts
... View more
03-30-2020
03:21 PM
|
0
|
3
|
2570
|
|
POST
|
Yup....syntax just the ' on front and backside.....everything seems to be working.....thank you all for your thoughts and pointers....cheers....stay safe
... View more
03-30-2020
03:00 PM
|
0
|
0
|
2146
|
|
POST
|
I think I might have it....I copied the string and remove the ' on the beginning and end and I think I can now pass it as a parameter... Still testing
... View more
03-30-2020
01:16 PM
|
0
|
1
|
2146
|
|
POST
|
One more thing....I am very confused on I can get this to work from running the python script seen below using the dataInputParameter variable ALTHOUGH I am trying to run this from a ESRI tool that passes in a parameter If I change the below code to accept the dataInputParameter1 variable which is the STRING being passed to it from the ESRI Tool it blows up textDict = json.loads(dataInputParameter1) So I change to the code above Copy the text from the dataInputParameter variable seen below Launch the tool and paste that into the parameter and submit it blows up. BUT as you can see I have a second parameter that returns results....I am returning all 3 Variables seen below...and the ONLY difference is that when I return the 3rd variable (the one that works when I define it) is it missing the single ' on the beginning and end.... QUESTION: do I need to strip the variable that I am grabbing from the GetParametersAsText????? Why does it work with a manual variable and not the parameter text? MESSAGE Variable 1: is the dataInputParameter1 variable that is created from the string being passed for the Tool MESSAGE Variable 2: is the dataInputParameter2 variable simply set form the getParameterAsText variable MESSAGE Variable 3: is the variable that I create with the text seen below...this is ALSO the text that I copy into the string parameter in the ESRI Tool dataInputParameter1 = arcpy.GetParameterAsText(0)
dataInputParameter2 = dataInputParameter1
dataInputParameter = '{"employees":[{"address":"1520 Split Oak Ln, Henrico, Virginia, 23229","distance":"10", "id" : "1" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"113 Buffalo Rd, Clarksville, Virginia(VA), 23927","distance":"50", "id" : "4" },{"address":"8817 Sherando Dr, Bristow, Virginia(VA), 20136","distance":"20", "id" : "5" }]}'
varaddress = ""
vardistance = ""
varid = ""
textDict = json.loads(dataInputParameter)
for employee in textDict['employees']:
varaddress = employee["address"]
vardistance = employee["distance"]
varid = employee["id"]
print ("address: " + varaddress)
print ("distance: " + vardistance)
print ("uniqueid: " + varid)
print ""
msg1 =("MESSAGE Variable 1: " + dataInputParameter1)
msg2 =("MESSAGE Variable 2: " + dataInputParameter2)
msg3 =("MESSAGE Variable 3: " + dataInputParameter)
msg4 = (msg1 + msg2 + msg3)
arcpy.AddMessage(msg4)
resultMsg = msg4
arcpy.SetParameterAsText(1, resultMsg) Executing: CreateMultiPolyBatch '{"employees":[{"address":"1520 Split Oak Ln, Henrico, Virginia, 23229","distance":"10", "id" : "1" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"113 Buffalo Rd, Clarksville, Virginia(VA), 23927","distance":"50", "id" : "4" },{"address":"8817 Sherando Dr, Bristow, Virginia(VA), 20136","distance":"20", "id" : "5" }]}'
Start Time: Mon Mar 30 16:08:57 2020
Running script CreateMultiPolyBatch...
MESSAGE Variable 1: '{"employees":[{"address":"1520 Split Oak Ln, Henrico, Virginia, 23229","distance":"10", "id" : "1" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"113 Buffalo Rd, Clarksville, Virginia(VA), 23927","distance":"50", "id" : "4" },{"address":"8817 Sherando Dr, Bristow, Virginia(VA), 20136","distance":"20", "id" : "5" }]}'
MESSAGE Variable 2: '{"employees":[{"address":"1520 Split Oak Ln, Henrico, Virginia, 23229","distance":"10", "id" : "1" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"113 Buffalo Rd, Clarksville, Virginia(VA), 23927","distance":"50", "id" : "4" },{"address":"8817 Sherando Dr, Bristow, Virginia(VA), 20136","distance":"20", "id" : "5" }]}'
MESSAGE Variable 3: {"employees":[{"address":"1520 Split Oak Ln, Henrico, Virginia, 23229","distance":"10", "id" : "1" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },{"address":"113 Buffalo Rd, Clarksville, Virginia(VA), 23927","distance":"50", "id" : "4" },{"address":"8817 Sherando Dr, Bristow, Virginia(VA), 20136","distance":"20", "id" : "5" }]}
Completed script CreateMultiPolyBatch...
Succeeded at Mon Mar 30 16:08:57 2020 (Elapsed Time: 0.11 seconds)
... View more
03-30-2020
01:13 PM
|
0
|
2
|
2146
|
|
POST
|
I can get my string to this in python but need to loop through and set each of the items to variables DATA: '{"employees":[{"address":"113 Buffalo Rd, Clarksville, VA 23927","distance":"50","id" : "4"},{"address":"8817 Sherando Dr, Bristow, VA 20136","distance":"20","id" : "5" }]} '
JSON: "{\"employees\":[{\"address\":\"113 Buffalo Rd, Clarksville, VA 23927\",\"distance\":\"50\",\"id\" : \"4\"},{\"address\":\"8817 Sherando Dr, Bristow, VA 20136\",\"distance\":\"20\",\"id\" : \"5\" }]} "
ENCODED: "{\"employees\":[{\"address\":\"113 Buffalo Rd, Clarksville, VA 23927\",\"distance\":\"50\",\"id\" : \"4\"},{\"address\":\"8817 Sherando Dr, Bristow, VA 20136\",\"distance\":\"20\",\"id\" : \"5\" }]} "
DECODED: {"employees":[{"address":"113 Buffalo Rd, Clarksville, VA 23927","distance":"50","id" : "4"},{"address":"8817 Sherando Dr, Bristow, VA 20136","distance":"20","id" : "5" }]}
... View more
03-30-2020
12:32 PM
|
0
|
0
|
2146
|
|
POST
|
In the original post the first part was in Python the second was in Javascript....that is what I am trying to pass as a parameter to the service and eventually the python scripts Here is an example of a shortened string '{"employees":[{"address":"113 Buffalo Rd, Clarksville, VA 23927","distance":"50","id" : "4"},{"address":"8817 Sherando Dr, Bristow, VA 20136","distance":"20","id" : "5" }]} '
... View more
03-30-2020
12:08 PM
|
0
|
2
|
2146
|
|
POST
|
I am passing the below from Javascript as a parameter string via a GP Service. Once I grab this in the python script I am trying to parse it.... I am trying to write variables for address, distance, and id for each record in a for loop....but having issues..thoughts? for item in textstring['employees']:
varaddress = item["address"]
print "address: " + varaddress var text = '{"employees":[' +
'{"address":"1520 Split Oak Ln, Henrico, Virginia, 23229","distance":"10", "id" : "1" },' +
'{"address":"1341 Research Center Dr Blacksburg, VA 24060","distance":"9", "id" : "2" },' +
'{"address":"816 W Main St, Danville, Virginia(VA), 24541","distance":"12", "id" : "3" },' +
']} ';
... View more
03-30-2020
11:39 AM
|
0
|
7
|
2201
|
|
POST
|
think I got it with this featureLayer.queryFeatures().then(function (results) {
featureLayer.applyEdits({ deleteFeatures: results.features }).then(function (results) {
alert("Im done and now building the multipart features");
});
});
... View more
03-30-2020
09:10 AM
|
0
|
0
|
2296
|
|
POST
|
hmmmm.. I added a ; at the end of appyEdits but no go... featureLayer.queryFeatures().then(function(results){
featureLayer.applyEdits({deleteFeatures: results.features}).then(results){
//do something here
};
});
... View more
03-30-2020
08:36 AM
|
0
|
2
|
2296
|
|
POST
|
so the shift+click and ctrl+click would replace the UI buttons? But with a bunch more code?
... View more
03-30-2020
08:05 AM
|
0
|
1
|
1131
|
|
POST
|
Is there a way to get an alert when the applyEdits is completed or successful? Want to verify its done and then write to the same FC.
... View more
03-30-2020
07:55 AM
|
0
|
4
|
2296
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-20-2018 11:09 AM | |
| 1 | 09-10-2018 06:26 AM | |
| 1 | 09-15-2022 11:02 AM | |
| 1 | 05-21-2021 07:35 AM | |
| 1 | 08-09-2022 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-19-2022
09:23 PM
|