I realize this might a very basic question but I am completely new to SSJS so thanks for the understanding.

In Marketing Cloud I am trying run SSJS script in order to update a field in a data extension. Using the available documentation I have put together the following:

<script runat=server language="JavaScript" executioncontexttype="Post" executioncontextname=test>

var TestDE = DataExtension.Init("TEST_DataExtension");
TestDE.Rows.Update({"AccountId":"Test_account"}, ["ContactId"],


The syntax seems to be correct and I can run the query via automation studio with no errors but the data extension is not getting updated the way I want it. In other words, field AccountId in TEST_DataExtension is not being changed to "Test_Account" for user with ContactId of 0032405071zljdyAAA.

Any idea why this might be?

  • easiest way to debug the script activities is to run it inside a landing page or cloud page. Outside of that, if you are more comfortable in AMPScript, you can have the AMPScript stored in a content area (classic only) and just have the SSJS call this content block. Mar 13 '17 at 17:10

Declaration of Server-Side JavaScript Block is incorrect and you have not included the SSJS libraries in your SSJS code.

<script runat=server language="JavaScript" executioncontexttype="get">

var TestDE = DataExtension.Init("TEST_DataExtension");
var result = TestDE.Rows.Update({"AccountId":"Test_account"}, ["ContactId"],["0032405071zljdyAAA"]);


Output: 1

  • Worked like a charm! Thanks a lot. Really appreciate the help Mar 14 '17 at 16:28
  • 2
    Good to know! Mark my answer if it has solved your problem.
    – Palash Rai
    Mar 14 '17 at 17:02

If you wish to debug SSJS in an Activity, you can use try/catch to grab the error and write it to a data extension:

<script runat = server language = "JavaScript">
Platform.Load("Core", "1.1.1");
try {
    writeErrorLog("process done");
catch (e) {
    var result = e.name + ": " + e.message;

function writeErrorLog(msg) {
    var errorLogDE = DataExtension.Init("ENT.errorlog");

I made a shared data extension with a message column of text that I can write to from anywhere in the JavaScript.


Try pasting it into a Cloud page or email and see what errors/status you get using Write(YOURVARIABLEHERE). My Guess at first glance is that it may be something to do with the JSON :D Doug

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.