Attribute only editing in Python Publish Web Layer Script

293
1
09-30-2021 08:02 AM
KBKnight
New Contributor III

All, thank you in advance for help on this. Need just a little bit of help changing a parameter. Thank you, thank you!

I have been using this script to upload web layers in model builder (so I can automate and run nightly):

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

I need to modify this script so that the enableEditing parameter allows users to ONLY update attributes. By deleting "Create, Delete" from the below line, I can disable creating new features and deleting existing:

capabilities += ",Create,Delete,Update,Editing"

BUT, that still allows the users to modify geometry AND attributes. I need to make it so that users in the field can only update an attribute (so we don't have accidental geometry changes). 

Help me Obi Wan! You're my only hope

0 Kudos
1 Reply
SzuNyiapTang
Esri Contributor

Hi @KBKnight ,

To do that, you need to update the allowGeometryUpdates to false in the service draft. You may refer to the snippet below to update.

doc = DOM.parse(outsddraft)
configProps = doc.getElementsByTagName('ConfigurationProperties')[0]
propArray = configProps.firstChild
propSets = propArray.childNodes
for propSet in propSets:
    keyValues = propSet.childNodes
    for keyValue in keyValues:
        if keyValue.tagName == 'Key':
            if keyValue.firstChild.data == "allowGeometryUpdates":
                keyValue.nextSibling.firstChild.data = "false"          
f = open(sddraft_output_filename, 'w')
doc.writexml(f)
f.close()

 

Cheers,

Tang

Cheers,
Tang
0 Kudos