My Python script tool runs from the geoprocessing pane in ArcGIS Pro 2.2, and what it does is create a new point in an SDE feature class and populate attributes. You could say that it is working, but the problem is that the new attributes for the point do not display in the attribute table until I perform more editing (manual, not via the script) on that feature class. The new attributes need to be seen immediately after the script ends.
I use an edit session in arcpy (my SDE feature class is versioned) and within that I do an update cursor for the new attributes. But somehow there seems to be a delay with edits being committed or the row getting updated or the edit session being saved.
Solved! Go to Solution.
I got it working!
The feature layer idea wasn't it at all...still using the feature layer, but what did work was actually very simple. At the very end of my script, which is immediately after the StopEditing(True) statement, I added a Try/Except statement - where I added code to change the SDE database connection back to the Default version - since I was finished editing anyway. Maybe it just needed some code at the end to help the edit session complete and the SDE database to refresh, and the specific code I gave it really didn't matter what that was. I'm not sure.
are you using the Editor within arcpy?
Dan,
Yes, I am using arcpy.da.Editor and arcpy.da.UpdateCursor. And earlier in the code I use arcpy.ChangeVersion_management to set the specific version of the data that I am editing, and I also called arcpy.CreateDatabaseConnection_management to set a connection specifically for that version.
I had a sort of similar case where the solution was to "Disable Caching" on the layer in question: Right Click layer in TOC, Properties, Cache....
Thanks Thomas, good suggestion, I tried it but it didn't change anything.
@LeeBrannon1 Hi Brannon,
I am building a script tool using changeversion, have you ever try to create a dropdown list of all the versions in a default.sde?
No, I have not tried to create a dropdown list of sde versions. My experience with changeversion is limited to just the script tool that was the subject of this post.
Does your script tool have a normal output parameter, or use a derived output parameter?
No output parameter that I am aware of, although I'm a little confused by the question. The script tool updates data and then ends, no further processing.
Could this problem be related to my using a feature layer as the input to the Update Cursor (within the edit session)? Would it behave better if I used the original SDE feature class instead?
The reason that I use a feature layer instead of the actual feature class is because I had to change the version of the database, and that tool required a feature layer.