Select to view content in your preferred language

Publish and overwrite web layers in ModelBuilder

1205
10
06-12-2023 09:46 AM
jennahlers
New Contributor II

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:

https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping/publish-and-overwrite-web-layers-in-mod...

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.

0 Kudos
10 Replies
DanPatterson
MVP Esteemed Contributor

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)

... sort of retired...
0 Kudos