AnsweredAssumed Answered

How to use DefaultValues on IFields for FeatureClasses?

Question asked by Kaspatoo on Mar 8, 2012
Latest reply on Mar 8, 2012 by Neil

I create a FeatureClass with some different Fields. After that I add a couple of Features to this FeatureClass.
One of the fields, called CreationDate, shall have every time the same value for all added Features where the other Fields-values will differ from each other.

I would really like to make use of the DefaultValue2 Property of the IField Interface to store that specific creation Date "automatically" for all features being added.
In my mind I would expect that when I add/ create a new feature in the FeatureClass and I do not set a value explicity for the Field "CreationDate" the DefaultValue will be used and stored on that Field.
The Problem is, after all, the Field "CreationDate" is still empty as I never had set it.

Thanks for any help.

Here some code I use for:

//Creating Fields to be added List<IField> fieldsToBeAdded = new...; addFields.Add(GISUtilities.GISUtilities.createNewField(tmp, esriFieldType.esriFieldTypeString, tmp, false, 100, dateString));  IFields fields = new FieldsClass(); IFieldsEdit fieldsEdit = (IFieldsEdit)fields;  //Add all Fields to be Added foreach (IField addField in fieldsToBeAdded) {     fieldsEdit.AddField(addField); }  featureClass= workspace.CreateFeatureClass(featureString, fields, null, null, abc.FeatureType, abc.ShapeFieldName, null);  //some Code which sets values explicity for all Fields except the field CreationDate (I debugged it, it is not set by mistake)  //Add Features using IFeatureCursor insertCursorAuswahl.InsertFeature(featureBufferAuswahl);   //After this statement I would expect the defaultValue Assigned, but my debug shows me still empty fields value = ""   //StopEditing and so workspaceEdit.StopEditing(true);  insertCursor.Flush(); return featureClass;