1

I am using Add() function to add a new data extension and I would like to access a status message if possible. I am using following code

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

var myDE = DataExtension.Add(deObj);

Data extension is created succesfully.

Variable myDE returns following, I don't know what it means

{ 
   "Fields":{ 
      "Add":"function",
      "Remove":"function",
      "Retrieve":"function",
      "Update":"function",
      "UpdateSendableField":"function"
   },
   "Remove":"function",
   "Update":"function",
   "Rows":{ 
      "Lookup":"function",
      "Add":"function",
      "Remove":"function",
      "Update":"function",
      "Retrieve":"function"
   }
}

Can you please advise what it means when it writes function everywhere?

Is there a way to return status, something like Success or Error? Thank you

1

So basically what you are seeing is the 'success' message. If it did not work, it would actually force an error on the page (Jint.Native.JsException throws "Error adding data extension").

What I would recommend is using a Try/Catch around it and you can set a value inside of it to show success or fail for your records.

E.g.

try{
  var myDE = DataExtension.Add(deObj);
  var status = 'Success';
  return status;
} catch(e) {
  var status = 'Fail';
  return status;
} 

This should help you handle errors better and provide the status of the call as well.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.