Skip to main content

Create a new data extension using SSJS from a file drop

I am attempting to create a new DE in SFMC from a csv file drop using SSJS. There's many resources that references the ability to do this using SSJS, but I am looking for assitance on why it's not working for me. The file is being dropped successfully using triggered_automations Queue Files: On Filename Pattern Settings: Begins with mydatafile_, with step 1 being the ssjs script with the attached code.

<script runat="server">
Platform.Load("Core", "1.1.2");
 try {
      var deObj = {
          CustomerKey: Platform.Function.GUID(),
           Name: "TestDE",
           Fields: [
                    {
                      Name: "Id",
                      FieldType: "Number",
                      IsPrimaryKey: true,
                       IsRequired: true
                    },
                    { 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);
    
            if (de && de.Status == "OK") {
                Write("(+) Data Extension was created successfully.<br>");
            } else {
                Write("(!) Data Extension was not created.<br>");
            }
        } catch (err) {
            Write(
                "(!) Data Extension was not created. Error message: " +
                    err.message +
                    "<br>"
            );
        }
</script>

I am having an issue with the automation process. The problem is that after dropping the file, the process is not creating the expected Data Extension (DE) in the specified test folder under the Data Extension category ID of 67001. I have attempted to resolve this issue by adding an executioncontexttype="Post" attribute, but it did not work. Then, I tried using the categoryID from the parent DE folder, but that did not work either. Lastly, I removed all the required text, but that did not work either.