AnsweredAssumed Answered

Determine if Feature is Versioned

Question asked by bulla_b on Apr 23, 2019
Latest reply on Apr 25, 2019 by bulla_b

Hi,

 

I'm creating an Editor Extension and in my Events.OnChangeFeature I need to determine if the current feature being edited is Versioned.  How do I do this??  Currently my code crashes at the casting of the IFeature to IVersionedObject3.

 

        //Invoked when a feature is created or modified.
        void Events_OnCreateChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
        {
            try
            {
                IFeature inFeature = (IFeature)obj;
               
                IVersionedObject3 vObject = (IVersionedObject3)inFeature;

                if (vObject.IsRegisteredAsVersioned)
                    if (inFeature.Fields.FindField("LASTUSER") != -1 && inFeature.Fields.FindField("DATEMODIFIED") != -1)
                    {
                        MessageBox.Show("Versioned....this will be edited.");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Fields not found");
                        return;
                    }

                MessageBox.Show("Not versioned!!");
                return;               
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

Outcomes