Skip to main content
1 of 2
Duc Le
  • 3.8k
  • 2
  • 8
  • 28

I have made some adjustments from your code. It should work in order to create a DE.

The main issue is that you put the field "Id" 2 times when you defined the DE.

<script runat="server">
Platform.Load("Core", "1.1.1");
try {
  var deObj = {
      CustomerKey: Platform.Function.GUID(),
      Name: "TestDE",
      Fields: [
          { Name: "Id", FieldType: "Number", IsPrimaryKey: true, IsRequired: true},
          { Name: "Text", FieldType: "Text", MaxLength: 100 },
          { Name: "Date", FieldType: "Date" },
          { Name: "Field4", FieldType: "Boolean", DefaultValue: "false" },
          { Name: "Email", FieldType: "EmailAddress", IsRequired: true },
          { Name: "ZipCode", FieldType: "Text", MaxLength: 5 }
      ],
      CategoryID: 67001
  };

  var de = DataExtension.Add(deObj);
  Write("(+) Data Extension was created successfully." + "<br>");

} catch (err) { 
  Write("(!) Data Extension was not created. Error message: " + err + "<br>")
  }
</script>

You can read this article from Ivan to know how to implement it properly.

Duc Le
  • 3.8k
  • 2
  • 8
  • 28