frozik

Prevent specific field editing for specific users in ArcMap

Discussion created by frozik on Aug 9, 2011
Latest reply on Aug 9, 2011 by dubravko.antonic-gdi-net-esridist
Hi, I have a task to lock fields editing for specific users. I started to check IEditEvents_Event with it's OnChangeFeature event, but I can't understand what exactly was changed and what was the original value. Also I failed all my attempts to undo changes. If I use IEditor.AbortOperation() it breaks ArcMap, if I use throw new COMException(msg, (int)0x80004005L) it does nothing.

As workaround for detecting field changes I came up with:
[PHP]
private void FeatureChanged(IObject feature)
        {
            var editor = _editor as IEditor;

            if (editor != null)
            {
                var workspaceEdit = (editor.EditWorkspace as IWorkspaceEdit2);
                var changes = workspaceEdit.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinOperation);
                var classes = changes.ModifiedClasses;

                var @class = classes.Next();

                var cursor = changes.ExtractEx(@class, esriDifferenceType.esriDifferenceTypeUpdateNoChange);

                // Prepare the output parameters.
                int featureID = -1;
                IRow sourceRow = null;
                IRow differenceRow = null;
                ILongArray fieldIndexes = null;

                // Iterate through the cursor.
                cursor.Next(out featureID, out sourceRow, out differenceRow, out fieldIndexes);
                while (featureID != -1)
                {
                    for (int i = 0; i < fieldIndexes.Count; i++)
                    {
                        var index = fieldIndexes.get_Element(i);

                        if (index >= 3) // Stub
                        {

                        }
                    }

                    cursor.Next(out featureID, out sourceRow, out differenceRow, out fieldIndexes);
                }
            }
        }
[/PHP]

But the logic is very disgusting as I don't work with feature which came in handler.

So the question is - how to detect feature attribute changes for concrete columns, and undo it in some cases correctly?

Outcomes