Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save katydorjee/8c831db066c217c2f2adbf1fd19bc499 to your computer and use it in GitHub Desktop.

Select an option

Save katydorjee/8c831db066c217c2f2adbf1fd19bc499 to your computer and use it in GitHub Desktop.
Updating Data Extension Records Using SSJS in SFMC
<script runat="server">
Platform.Load("core", "1");
try {
var de = DataExtension.Init("DataExtensionExkey");
var payload = {
Status : "Active",
EmailAddress : "[email protected]"
};
var result = de.Rows.Update(
payload,
["SubscriberKey", "003ABCDEFGH"]
);
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
@katydorjee
Copy link
Author

SSJS Script Overview
This script updates a record in a Data Extension (DE) in Salesforce Marketing Cloud.

Key Components:

  1. Platform.Load("core", "1"): Loads the Core library to enable server-side functionality in SFMC.
  2. DataExtension.Init("DataExtensionExkey"): Initializes the DE using its external key.
  3. payload: An object with fields to be updated in the DE — here, it sets Status to "Active" and EmailAddress to "[email protected]".
  4. de.Rows.Update(): Performs the update operation using the primary key, SubscriberKey, with the value "003ABCDEFGH".
  5. Try/Catch block: Handles any errors gracefully and logs the result or error using Write(Stringify(...)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment