I copied this code and ran it against a versioned feature class in enterprise sde (Oracle 12.1). It fails with "Edit operation failed." as the edit operation error message. I'm trying to take the selected feature make a copy and update some attributes is this the best way? Should I try some other method?
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); var layer = ArcGIS.Desktop.Mapping.MapView.Active.Map.FindLayers("WATERLINE").FirstOrDefault() as BasicFeatureLayer; insp.Load(layer, 364323); // modify attributes if necessary // insp["Field1"] = newValue; insp["STATUS"] = 9; //Create new feature from an existing inspector (copying the feature) var createOp = new ArcGIS.Desktop.Editing.EditOperation(); createOp.Name = "Create from insp"; createOp.Create(insp.MapMember, insp.ToDictionary(a => a.FieldName, a => a.CurrentValue)); createOp.Execute(); });
Jimmy,
The other syntax to try is the create method with a mapmember and inspector:
EditOperation.Create(ArcGIS.Desktop.Mapping.MapMember, ArcGIS.Desktop.Editing.Attributes.Inspector, System.Action<long>)
Can you create a feature in the layer through the UI with that status value? Just checking if there's a constraint.
I tried your snippet on a SQLServer data and it worked as expected. You can try to look at the error by adding this:
createOp.Create(insp.MapMember, insp.ToDictionary(a => a.FieldName, a => a.CurrentValue));
var createResult = createOp.Execute();
if (createResult != true || createOp.IsSucceeded != true)
MessageBox.Show ($@"Create failed: {createOp.ErrorMessage}");
Thanks for the prompt responses. I spend more time today trying to find out what’s happening.
It’s just when I use EditOperation.Create against enterprise sde classic versioning that it fails. There are attribute rules I will disable them and try this tomorrow. Any other suggestions would be helpful?
I'm now seeing the same behavior using ArcGIS Pro 2.8.3 and connecting to Utility Network branched versioned services from ArcGIS enterprise 10.9.