Add

Creates a data extension and returns an initialized DataExtension object.

Syntax 

Add(1)

Function Properties 

OrdinalTypeDescription
1ObjectRequired. 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.

1var deObj = {
2    CustomerKey : "SendableDE",
3    Name : "Sendable Data Extension",
4    Fields : [
5        { "Name" : "SubKey", "FieldType" : "Text", "IsPrimaryKey" : true, "MaxLength" : 50, "IsRequired" : true },
6        { "Name" : "SecondField", "FieldType" : "Text", "MaxLength" : 50 },
7        { "Name" : "ThirdField", "FieldType" : "Text", "MaxLength" : 50 },
8        { "Name" : "DifferentSubKey", "FieldType" : "Text", "MaxLength" : 50 }
9    ],
10    SendableInfo : {
11        Field : { "Name" : "SubKey", "FieldType" : "Text" },
12        RelatesOn : "Subscriber Key"
13    }
14};
15
16var de = DataExtension.Add(deObj);

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