0

I am trying to create a Data Extension using SSJS Script through Automation Studio.

My script is as follows:

  <script runat="server">
   platform.load("core","1.1");
   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);
 </script>

But it keeps giving me an error when I run the automation, even if I only have the platform.load("Core","1.1") line in my script it still shows error :( ..

is that possible to create DE using script through Automation Studio?

If so why platform.load("Core","1.1") is not working for me? Do I need to do anything extra to enable these functions?

Or is there any other way to run this script on a landing page, if so can someone advice me how to do this?

Many Thanks

0

1 Answer 1

1

Platform.Load (used to load the core library) is case sensitive. You will need to use Platform.Load instead of platform.load.

Also, I would recommend removing the comma after the Field 3 object in your array. It will work if you include it, but it's not strictly valid.

The following code works. However, note that the script will fail if a DE already exists with the same name and external key.

<script runat="server">
Platform.Load("core","1.1");
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);
</script>
0

You must log in to answer this question.

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