ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / FieldDescription Class / SetDefaultValue Method
The default value of the ArcGIS.Core.Data.Field.
The specific subtype code for the ArcGIS.Core.Data.Field's default value. This argument is optional. If it is not set or is set to null, the field's default value at the table level is set.
Example

In This Topic
    SetDefaultValue Method
    In This Topic
    Sets the default value of the ArcGIS.Core.Data.Field at the table level if subtypeCode is not specified. Otherwise, sets the default value for the specific subtype code.
    Syntax
    Public Sub SetDefaultValue( _
       ByVal defaultValue As Object, _
       Optional ByVal subtypeCode As Nullable(Of Integer) _
    ) 
    public void SetDefaultValue( 
       object defaultValue,
       Nullable<int> subtypeCode
    )

    Parameters

    defaultValue
    The default value of the ArcGIS.Core.Data.Field.
    subtypeCode
    The specific subtype code for the ArcGIS.Core.Data.Field's default value. This argument is optional. If it is not set or is set to null, the field's default value at the table level is set.
    Example
    Modifying an existing field
    {
      // Must be called within QueuedTask.Run
      void ModifyExistingField(SchemaBuilder schemaBuilder, TableDefinition tableDefinition, string fieldNameToBeModified = "PropertyAddress")
      {
        Field field = tableDefinition.GetFields().FirstOrDefault(f => f.Name.Contains(fieldNameToBeModified));
    
        // Update field's alias name and length
        FieldDescription fieldDescription = new FieldDescription(field)
        {
          AliasName = "Physical Property Address",
          Length = 50
        };
    
        // Update the default value
        fieldDescription.SetDefaultValue("123 Main St");
    
        // Enqueue modify operation
        schemaBuilder.Modify(new TableDescription(tableDefinition), field.Name, fieldDescription);
    
        // Execute DDL
        schemaBuilder.Build();
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.1 or higher.
    See Also