0

I was trying to create a data extension based on the value that i get from the sync de. Could anyone tel me what exactly the issue is, in my code. When i try to run this in the automation studio script activity, it throws an error.

<script runat=server>
Platform.Load("Core","1");

//initialize the current time
var currentTime = Now();

//initialize the sync de to fetch the de details
var initde = DataExtension.Init("Community_Sheet__c_Salesforce");

//lookup in the initialized de with the date field
var lookupinitde = initde.Rows.Lookup(["CreatedDate"],["2018-01-05T13:43:31.000"]);

try {
    if (lookupinitde.length > 0) {
        for (var i = 0; lookupinitde.length > i; i++) {

            var dename = lookupinitde[i]["Marketing_Name__c"] ;

            // initialize de creation code
                var sdeObj = {
                  CustomerKey : dename,
                  Name : dename,       
                  Fields : [
                      { "Name" : "SubscriberKey", "FieldType" : "Text", "MaxLength" : 254, "IsRequired" : true, "IsPrimaryKey" : true },
                      { "Name" : "FirstName", "FieldType" : "Text",  "MaxLength" : 50 },
                      { "Name" : "LastName", "FieldType" : "Text", "MaxLength" : 50 },
                      { "Name" : "EmailAddress", "FieldType" : "EmailAddress","MaxLength" : 255 }

                  ],
                  SendableInfo : {
                      Field : { "Name" : "SubscriberKey", "FieldType" : "Text" },
                      RelatesOn : "Subscriber Key"
                  }

                };

              var newDE = DataExtension.Add(sdeObj);
               Write(Stringify(newDE));
        } 

    }
    else{
        var dename = "DEname not found"
    }
}
catch (e) {
  Write("<br>Exception: " + e);
}
</script>
  • What happens if you move your try { up above var currentTime = Now();? – Adam Spriggs Nov 28 '18 at 14:28
  • i figured it out, when i removed the "max length" from the email address and ran the automation, it worked. I'm able to see the data extension in the folder. Thanks :) – Abhishek Nov 28 '18 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.