MARKETING CLOUD / SSJS
SSJS
Server-Side JavaScript in Marketing Cloud — what works, what blows up at scale, and the patterns we reach for in CloudPages and Code Resources.
Foundation · 2
Production note
MC SSJS gotchas: what actually fires in production
Server-Side JavaScript in Marketing Cloud is JavaScript the way it was in 2010 — SpiderMonkey 1.7, no modern syntax, single-threaded, with a Salesforce-specific Platform API on top. Ten gotchas Cleon hit at production scale, with the patterns that survive.
Decision framework
Marketing Cloud SSJS: Style Guide
The opinionated rules Cleon applies to every Server-Side JavaScript block we ship in Marketing Cloud — naming, formatting, commenting, patterns to prefer, anti-patterns to refuse — distilled from the gotchas and reference pages into a single discipline document.
Reference · 8
Reference
Basics — Marketing Cloud SSJS fundamentals
Where SSJS runs in Marketing Cloud, what runtime you actually have (SpiderMonkey 1.7), and the two main contexts — CloudPage rendering vs Automation Script Activity — that decide the patterns you reach for.
Reference
Platform.Function — Marketing Cloud SSJS reference
The core SSJS API namespace — Data Extension reads and writes (LookupRows, InsertData, UpdateData, UpsertData, DeleteData) plus the helpers you reach for in every script (GUID, Now, ParseJSON). What works as documented, what has silent traps, and the patterns we land on.
Reference
WSProxy — Marketing Cloud SSJS reference
The SOAP API wrapper for SSJS — when Platform.Function isn't enough. Retrieve / Create / Update / Delete with full filter support, pagination past 2500 rows, and the auth-token refresh pattern that keeps long scripts alive.
Reference
String functions — Marketing Cloud SSJS reference
The string operations available in MC SSJS — native JavaScript methods (the ES5 subset SpiderMonkey 1.7 supports) plus the Platform.Function helpers for formatting and stringification. What's safe, what's missing, and what you have to polyfill.
Reference
Date functions — Marketing Cloud SSJS reference
Date and time handling in SSJS — Now / DateAdd / DateDiff / DatePart plus the native JavaScript Date object's ES5 methods. Same UTC trap as SQL, plus the date-part string codes you have to memorize.
Reference
Encoding functions — Marketing Cloud SSJS reference
Base64 and URL encoding in MC SSJS — the four Platform.Function helpers, when each is the right answer, and the round-trip pitfalls (whitespace, line wrapping, character set) that bite at scale.
Reference
Hashing functions — Marketing Cloud SSJS reference
SHA256, SHA1, MD5, HMAC — when each is the right answer in MC SSJS, the hex-vs-Base64 output trap, and why MD5 is still around for tracking pixels but not for anything that matters.
Reference
Util · Variable · Request — Marketing Cloud SSJS reference
The bridges between SSJS and the surfaces around it — Variable for AMPscript interop, Request for CloudPage URL/form access, Platform.Function.RaiseError + GetSetting for control flow and config. The grab-bag page that ties the catalog to its neighbors.
How-to · 3
How-to
Debugging stuck Script Activities
When a Script Activity ran past its budget, finished without doing what it should, or reported 'Completed' while quietly skipping half the work, the diagnostic is the same. Six queries against the log DEs the script left behind that find where it died.
How-to
Debugging WSProxy auth issues
The first 1,000 WSProxy calls work, then everything past minute 20 returns 'Token has expired'. Or auth fails on call one with no obvious reason. Five queries against your log DEs that separate the timeout pattern from the credentials pattern from the multi-BU pattern.
How-to
Debugging silent UpsertData duplicates
A Script Activity ran cleanly but downstream counts are wrong. UpsertData inserted duplicates instead of updating because the destination DE's primary key is missing or misconfigured. Six queries that confirm the silent-insert pattern and walk through the recovery.