I'm trying to create new features in a Utility Network feature service by using a series of EditOperation.CreateEx() calls. The first time I run the process, each feature is created exactly as expected, but if I try to run the same process again, I get a failed result with the error "ERROR: Unable to complete operation., The row contains a bad value." The code below is fundamentally what I'm running, though pared down a bit for simplicity. I have every reason to believe the fields I'm creating are correct. I'm checking subtypes, domain values, length, type, etc.
A couple other things are fishy about the first edit operation too. It doesn't create any new entries on the undo stack, regardless of setting long or short to the EditOperationType, and when I set SelectNewFeatures they are not selected when the operation finishes.
This makes me believe something is failing at the end of the first operation, and it is not closing a process or exiting gracefully, but I don't know what to change to fix that. Is there a smoking gun that I'm overlooking?
I also found this help article, which doesn't illuminate the matter very much.
public async Task RegenerateSelectedRecord()
{
CancelableProgressorSource progressorSource = new CancelableProgressorSource("Restoring features...", "Cancelling restore...", true);
await QueuedTask.Run(
() =>
{
EditOperation editOperation = new EditOperation();
editOperation.Name = "Restoring deleted features";
editOperation.SelectNewFeatures = true;
// loop through the feature data to create
foreach (var newObject in this.featuresToRestore)
{
// get the field values
var bufferValues = newObject.GetValues();
// get the table
var table = newObject.GetTable();
RowToken rowToken = editOperation.CreateEx(table, bufferValues);
editOperation.Execute();
// the above succeeds on each row the first time it's called.
editOperation = editOperation.CreateChainedOperation();
// do something with the row token to make sure it was created
}
// I do more stuff with the edit operation, removing this does not change the result
// I add relationships and associations to the restored row here, they are created as expected the first time
// later down the road, execute the last step if anything got missed
if (!editOperation.IsEmpty)
{
editOperation.Execute();
}
}, progressorSource.Progressor);
}