AnsweredAssumed Answered

Why does IFieldChecker change the name of OID field?

Question asked by Will.Walker on Apr 26, 2019

The documentation for IFieldChecker states that the interface checks for errors in field names.  Specifically, it renames the OID field to "ObjectID" based on 4 cases.  When creating a standalone table in a geodatabase, using the IFieldsEdit interface to create the OID field, there are no requirements on what constitutes a valid name for the OID field.  However, if the OID field is not named "ObjectID" when fed to the FieldChecker, it is changed to "ObjectID".  What constitutes a valid OID field name?  Are there any restrictions on valid OID field names in a geodatabase?  Will naming my OID field something other than "ObjectID" cause issues?  See relevant code below:


    IFields fields = new FieldsClass();
    IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
    fieldsEdit.FieldCount_2 = 10;

    IField field = new Field();
    IFieldEdit fieldEdit = (IFieldEdit)field;
    fieldEdit.Name_2 = "MyOidFieldName";
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
    fieldsEdit.set_Field(0, field);


    // Add other fields here...


    // use IFieldChecker to create validated fields collection
    IFieldChecker fieldChecker = new FieldChecker();
    IEnumFieldError enumFieldError = null;
    IFields validatedFields = null;
    fieldChecker.ValidateWorkspace = (IWorkspace)fws;  //fws = my feature workspace
    fieldChecker.Validate(fields, out enumFieldError, out validatedFields);    //<--my OID field name is changed to "ObjectID"


arcobjects 10.4.1objectidfieldname