JavaScript, APIs, and Platform Scripting
Scripting surfaces
Server-side JavaScript runs in workflow JavaScript activities and in the JSAPI: xtk.queryDef builds queries, queryDef.create/get()/write()/del() operate on schemas, and logInfo/logError write to the workflow log. Workflow scripts see task, vars and instance.vars; instance.vars persists across the workflow run, local variables do not. The Campaign Standard API is REST-based: authenticate with a technical account and Adobe I/O credentials, pass X-Security-Token, and call resource endpoints with $filter, $select, $orderby and paging. SOAP-style NLWS calls belong to Campaign Classic, not Standard - a common distractor.
Traps
- JavaScript is case-sensitive:
recipientandRecipientdiffer; schema names are lowercase. queryDef.get()returns a collection; loop it correctly or you get empty results.- String concatenation into a query invites injection; use parameters.
write()on a new record needs the schema key fields.- API rate limits and pagination: one call does not return all records.
Rule of thumb
Keep workflow scripts idempotent: query by external ID, update if found, insert if not.
Worked example:
var q = xtk.queryDef.create(<queryDef schema="nms:recipient" operation="select"><select><node expr="@id"/></select><where><condition expr="@email" setOperator="equal" value={vars.email}/></where></queryDef>);
var res = q.ExecuteQuery();
for each (var r in res.recipient) logInfo("found " + r.$id);