ArcFM Desktop Overview > ArcFM Solution Basics > Autoupdaters > Using AUs to Cancel Edits |
The ArcFM Autoupdater component allows for AUs to raise an error that will cause the Autoupdater component to cancel the current edit and undo the changes that the edit has made. This is useful when a specific condition required by the edit is not met, necessitating the edit be undone. For example, a special AU could be written that requires a user to select a structure to which a newly added device is to be related. If a structure is not successfully selected by the user, the addition of the new device is cancelled. The data will be returned to the state in which it existed before the device was added.
The following code demonstrates how to cancel an edit using C#.
C# Snippet |
Copy Code
|
---|---|
throw new COMException("Error in xxx ", (int) mmErrorCodes.MM_E_CANCELEDIT); |
In your custom AUs, you will no doubt be using error handlers to trap unexpected errors. Whenever you raise this error, you’ll need to make sure that your error handling routine ignores it so that the ArcFM Autoupdater component receives the MM_E_CANCELEDIT code. Otherwise the error will be handled by your routines and the edit will never be cancelled. Raising MM_E_CANCELEDIT is the only valid method for cancelling an edit from an autoupdater. Do NOT use the AbortOperation() method, as this may corrupt the ArcGIS Undo stack.