1

I'm building a Data Extension using SSJS for the first time and the documentation is horrible. There's no syntax guide for the various field types.

I'm wondering what the purpose of the "Ordinal" parameter in the definition of the Date field in the example below from the help page means.

Anyone know?

var deObj = {
        "CustomerKey" : "demoDE",
        "Name" : "My Demo DE",
        "Fields" : [
          { "Name" : "Field 1", "FieldType" : "Number", "IsPrimaryKey" : true, "IsRequired" : true },
          { "Name" : "Field 2", "FieldType" : "Text", "MaxLength" : 50 },
          { "Name" : "Field 3", "FieldType" : "Date", "Ordinal" : 2 },
        ]
    };

var myDE = DataExtension.Add(deObj);

1 Answer 1

3

The ordinal denotes the position of the field in the table. The field with Ordinal zero is the left most field. The property is read-only and has no effect in the example. The SOAP API, and by extension WSProxy, ignore the value you provide and create the fields in the order you provide them in your API payload.

var de = {
      "CustomerKey" : "demoDE",
      "Name" : "My Demo DE",
      "Fields" : [
         {"Name":"Field3","FieldType":"Text","MaxLength":50,"Ordinal":2},
         {"Name":"Field2","FieldType":"Text","MaxLength":50,"Ordinal":1},
         {"Name":"Field1","FieldType":"Text","MaxLength":50,"Ordinal":0}
      ]
};

var api = new Script.Util.WSProxy();
api.createItem("DataExtension",de,{});

var fields = api.retrieve("DataExtensionField",["Name","Ordinal"],{
        Property: "DataExtension.CustomerKey",
        SimpleOperator: "equals",
        Value: "demoDE"
}).Results;

for (var f = 0; f < fields.length; f++) {
    Write(fields[f].Name + ' - ' + fields[f].Ordinal + '<br>');
}

Output

Field3 - 0
Field2 - 1
Field1 - 2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .