Passing user input into Geoprocessing service as dataset

69
7
02-13-2020 09:15 AM
Highlighted
New Contributor II

I have a script tool that runs in ArcGIS Desktop and a slightly modified copy that runs in ArcGIS Pro. The tool takes input from a user via arcpy.GetParameterAsText. This input corresponds with the name of a layer in map. The text string is then passed into a series of geoprocessing steps.

The tool is published to Portal however, when I try and run it in a web app I get an error which reads File "e:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\geoprocessing\_base.py", line 368, in describe self._gp.Describe(*gp_fixargs(args, True))) OSError: "Layer Name" does not exist. Is there something I am needing to do to convert the text string value to JSON so that the geoprocessing steps in the script will recognize the appropriate layer? 

Tags (2)
Reply
0 Kudos
7 Replies
Highlighted
Esri Frequent Contributor

The script needs to know to get valid layer names from the original map document, which are the same layers in your webmap. The Extract Data Task sample does a good job of illustrating this:

Extract Data Task—Help | ArcGIS Desktop 

Once the layers are in your original map document or TOC, those are the layers that will be used with the GP tool. The layers in the webmap aren't directly accessed to get the data, they're somewhat used as a reference to draw the bounding box.

Reply
0 Kudos
Highlighted
New Contributor II

Thanks Jonathan, the layer names in the map doc do match what is in the Value List in the parameters of the arcpy.GetParameterAsText function though it is showing the layer name as not existing.

Reply
0 Kudos
Highlighted
MVP Regular Contributor

Is this 1 mxd? Is it registered to the data store?

Reply
0 Kudos
Highlighted
New Contributor II

It is 1 mxd, the data hits SDE directly.

Reply
0 Kudos
Highlighted
MVP Regular Contributor

Is the mxd in the data store and the data referenced in the mxd through a full network path?

Reply
0 Kudos
Highlighted
New Contributor II

It is not in the data store. The data is referenced using a UNC just the layer name. I was thinking I may need to include an os.path.join to get it to hit the actual feature class.

Reply
0 Kudos
Highlighted
MVP Regular Contributor

I think the mxd needs to be in the datastore as you're setting the workspace then using list layers I guess?

Reply
0 Kudos