Add

Creates a data extension and returns an initialized DataExtension object.

Syntax

Add(1)

Function Properties

Ordinal Type Description
1 Object Required. An object that specifies the properties of the new data extension.

Examples

This code example creates a sendable data extension that contains four fields. The field SubKey is associated with the contact’s subscriber key.

var deObj = {
    CustomerKey : "SendableDE",
    Name : "Sendable Data Extension",
    Fields : [
        { "Name" : "SubKey", "FieldType" : "Text", "IsPrimaryKey" : true, "MaxLength" : 50, "IsRequired" : true },
        { "Name" : "SecondField", "FieldType" : "Text", "MaxLength" : 50 },
        { "Name" : "ThirdField", "FieldType" : "Text", "MaxLength" : 50 },
        { "Name" : "DifferentSubKey", "FieldType" : "Text", "MaxLength" : 50 }
    ],
    SendableInfo : {
        Field : { "Name" : "SubKey", "FieldType" : "Text" },
        RelatesOn : "Subscriber Key"
    }
};

var de = DataExtension.Add(deObj);

For information about specifying data extension fields, see Fields.Add.