Fields.Add

Adds a field to a data extension.

Fields.Add(1)

OrdinalTypeDescription
1ObjectAn object that specifies the properties of a data extension field.

The field object can contain these properties.

NameTypeDescription
CustomerKeyStringA unique ID for the field.
DefaultValueString or NumberThe default value that’s applied to the field if one isn’t provided when a row is added to the data extension.
FieldTypeStringThe type of field. Possible values:
  • Boolean
  • Date
  • Decimal
  • EmailAddress
  • Locale
  • Number
  • Phone
  • Text
IsPrimaryKeyBooleanIndicates whether the value of the field is used as a primary key. If true, the value is used as a primary key.
IsRequiredBooleanIndicates whether a value must be provided for the field when a row is added to the data extension. If the value is true, the data extension field is required.
MaxLengthIntegerThe maximum number of characters that can be specified in the value of a field. For a Text field, the value must be an integer that’s greater than 0 and less than or equal to 4000, and the default value is 50. For a Decimal field, this value specifies the maximum number of digits before and after the decimal point, and the maximum value is 29.
NameStringRequired. The name of the field.
OrdinalIntegerThe position of the field in the data extension. The ordinal value is used when displaying the data extension in Contact Builder.
ScaleIntegerThe number of digits that can follow the decimal point in a Decimal field. The minimum value is 0 and the maximum value is 8.

For more information, see Data Extensions Data Types in Email Studio.

This code example adds a field to an existing data extension.

For information about creating a data extension and adding fields, see DataExtension.Add.