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?
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:
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.
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.
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.