EditOperation failed

644
2
Jump to solution
05-30-2022 12:45 PM
BrianBulla
Occasional Contributor III

Hi,

I'm trying to troubleshoot some editing issues with a custom tool.  When the following code runs, most of the time I get the "success" message, but occassionally get the error message.  The error message that the EditOperation gives is pretty vague though.  Is there another way to get more detailed info about why the error is happening??

if (editOperation.Execute() == true)
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(updatedFeatures.ToString() + " features updated.", "Fittings Tool - Update Complete");
                    else
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(editOperation.ErrorMessage.ToString() + "\n" + "\n" + "Please try again using the current selection.  If the problem persists, let Brian know.", "Fittings Tool - ERROR");

BrianBulla_0-1653939882827.png

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Hi Brian, 

 

In the case where you are calling EditOperation.Modify with an inspector object that has not actually changed any attributes, then internal optimizations will see this as an empty operation and won't actually add it to the list of work to be done when EditOperation.Execute  occurs. This is why the tracking fields are not updated on your feature.  Tracking fields are only updated when a change (attribute or spatial) is made to the record. 

In addition if there is no work to be done (ie EditOperation.IsEmpty returns true), then yes, an EditOperation.Execute will return false. 

In your situation, you can check the EditOperation.IsEmpty property and only call EditOperation.Execute if there is work to be done. 

 

Narelle

View solution in original post

2 Replies
BrianBulla
Occasional Contributor III

OK, so I have been troubleshooting this and think I might be on to something.  So this tool I created edits a few different attributes on the selected, or even multiple selected features.  I have a loop to deal with multiple selected features so I use an Inspector and run a editOperation.Modify(insp) after each feature is processed.  At the end I commit all edits with EditOperation.Execute.

It seems like with one selected feature, EditOperation will return FALSE when there are no changes to any of the attributes on the feature.  And hence the error message based on my coding.  But why is this??  I also have editor tracking enabled and I can see that the DATEMODIFIED is not getting updated for features where the editOperation is not actually changing anything.

Is this "by design" that it only returns TRUE when attributes actually change (ie. overwriting attributes with the exact same values does not count as an 'edit').

Hopefully this makes sense.  Occasionally this tool is run on features just to make sure we have the attributes right, but if it keeps returning false then I'll have to update my coding.  I just want to make sure I am understanding why it is returning false.

0 Kudos
NarelleChedzey
Esri Contributor

Hi Brian, 

 

In the case where you are calling EditOperation.Modify with an inspector object that has not actually changed any attributes, then internal optimizations will see this as an empty operation and won't actually add it to the list of work to be done when EditOperation.Execute  occurs. This is why the tracking fields are not updated on your feature.  Tracking fields are only updated when a change (attribute or spatial) is made to the record. 

In addition if there is no work to be done (ie EditOperation.IsEmpty returns true), then yes, an EditOperation.Execute will return false. 

In your situation, you can check the EditOperation.IsEmpty property and only call EditOperation.Execute if there is work to be done. 

 

Narelle