I am trying to run the script below in the Marketing Cloud Script Activity to update data in a Data Extension:

<script  runat="server">
    try {
        var customers = DataExtension.Init("test_customer");
    } catch (ex) {

        Write("An error has occurred: " + Stringify(ex));

This script updates the Data Extension when inserted into a Landing page but it does not update the Data Extension when run from a Program, Automation or the Start Activity button.

Does anyone know what I could be doing wrong

  • Please provide some the details about the Data Extension you're wanting to update. What's the customer/external key? What are the columns and data types? Are are any of them required? Any primary keys defined? – Adam Spriggs Jul 21 '16 at 11:31
  • The DataExtensions has the following: text fields - Name(Primary Key) and AgentName; email field - Email, boolean fields - Sent (default to false). . They are all required. – thamsanqa Jul 21 '16 at 13:00
  • And the external/customer key? – Adam Spriggs Jul 21 '16 at 14:16
  • I would recommend adding code to your catch error statement that will append the error message to a data extension. For simplicity sake, create a DE (maybe named error_log) with a single text column, no column width, no primary key and make the field nullable. – David Devoy Jul 21 '16 at 17:50
  • Thanks for the logging suggestion it really helped me debug the eventual problem. See answer below – thamsanqa Jul 25 '16 at 7:03

It seems I was using the name of the Data Extension in the DataExtension.Init method instead of the External Key. For some reason the name of the Data Extensions works ok when

  • when the script is within a landing page
  • using the Add method when the script is called from a Script Activity

However the Update and Retrieve methods work in a Script Activity on if the External Key is used in the DataExtension.Init method first.

| 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.