I am trying to create a phyton script to create a geoprocessing tool to Publish and overwrite web layers within ModelBuilder. I am referring to the instructions within this blog post:
The issue that I’m having is the script provided in the link above contains the input “map” and what I would like to select is an input “layer” in the content pane.
Jonah Lay has provided sample code within the comments of the blog post here: https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#GUID-8E27A3ED-A...
The issue is when I try to use that code I continue to receive errors. Is there someone that could help debug this issue? I have zero coding experience.
NameError: name 'layer' is not defined
You don't define what 'layer' is in your inputs to the tool
# --- Where is 'layer' ???? ----
if __name__ == '__main__':
# ScriptTool parameters
map = arcpy.GetParameter(0)
service = arcpy.GetParameterAsText(1)
summary = arcpy.GetParameterAsText(2)
tags = arcpy.GetParameterAsText(3)
description = arcpy.GetParameterAsText(4)
overwriteService = arcpy.GetParameter(5)
enableEditing = arcpy.GetParameter(6)
enableSync = arcpy.GetParameter(7)
enableWFS = arcpy.GetParameter(8)
timezone = arcpy.GetParameterAsText(9)
share_public = arcpy.GetParameterAsText(10)
share_organization = arcpy.GetParameterAsText(11)
share_groups = arcpy.GetParameterAsText(12)
outdir = arcpy.GetParameterAsText(13)
rest_endpoint = ScriptTool(layer, service, summary, tags, description, overwriteService, enableEditing, enableSync, enableWFS, timezone, share_public, share_organization, share_groups, outdir)
arcpy.SetParameterAsText(1, rest_endpoint)
arcpy.AddMessage(rest_endpoint)