1

I have several editors making edits to a branch versioned, sde referenced layer on ArcGIS Portal. As part of the work flow, I want editors to open their ArcGIS Project saved with their edit version of the layer. The editor then creates features while referencing an attribute table that contains a UID and several other attribute values. The user will paste the UID into the corresponding field of the layer attribute table for the row of the newly created feature, saves the edit, and moves on to create a new feature.

During off hours, I want a script to run that builds a dict to group the missing attributes by UID and then uses arcpy.da.SearchCursor to add the missing values to the feature class on sde.

Here's what I have so far:

refTable = "C:\\Data\Views_DB_query.sde\\dbo.View_records"
fc = "C:\\Data\Layers_ac.sde\\AC.worklayer\\AC.workLayer"

# make list of fc records that need to be updated

UIDS = []
with arcpy.da.SearchCursor(fc, ["field1", "UID"]) as rows:
       for row in rows:
        if row[0] == None:
            UIDS.append(row[1])

# make a dict of UID keys, attribute values based on UIDS list

updates = {}
for i in UIDS:
    with arcpy.da.SearchCursor(refTable, ["UID","field1", "fieldn"]) as rows:
        for row in rows:
            if i == row[0]:
                updates[i] = row[1:]

# update missing branch versioned feature class attributes with values from dict

for k, v in updates.items():
    with arcpy.da.UpdateCursor(fc, ["UID","field1","fieldn"]) as rows:
        for row in rows:
            if k == row[0]:
                row[1] = v[0]
                row[2] = v[1]
            rows.updateRow(row)

I am getting the following error:

TypeError: cannot update branch versioned table

The actual layer has eight fields that need to be populated and I would like to avoid requiring the editors to have to copy and paste more than just the UID from the ref table and have the off hours python script take care of the rest. The script will also perform a post/reconcile prior to the update and a reconcile after the update so all of the versions have all of the edits done by each editor represented in the default version.

How can I get Python to update a branch versioned layer?

1 Answer 1

0

If I am reading the ESRI Doc right you need to access branch versioned items through a published REST Service. Look at the options in the ArcGIS for Python API it is focused on Services first. Or switch back to traditional versioning.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jun 6, 2023 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.