Reference for the Adobe Campaign JavaScript API: every function with its signature, parameters, real use cases, common pitfalls and performances tests.

It is built with quality coding, efficiency and security goals in mind, as well as enabling AI-assisted coding.

Categories

  • Database: query, read and write data, and manage instance options.
  • XML: load shared libraries and helpers.
  • Http: call external APIs and trigger webhooks with GET/POST requests.
  • Log: write messages to the server logs and the workflow journal.
  • Application: read the configuration & environement variables.
  • File: read, write and manage files on the server.
  • JSSP: build dynamic pages and JSON APIs with the request and response objects.
  • Security: escalate privileges, encrypt and escape values.

Example

Find below an example of an AC JS Reference entry: πŸ“• getOption.

getOption

Get an instance-specific setting from the xtk:option schema, useful for environment variable.

getOption(name: string, useCache: bool): any

Parameters

name string Internal name (@name) of the xtk:option record
useCache bool Use the server cache

Examples

getOption("NmsEmail_DefaultFromAddr"); // [email protected]
getOption("NmsServer_MirrorPageUrl"); // https://tracking.email.example.com

See also

  • πŸ“• setOption - Set an instance-specific setting in the native xtk:option schema, useful for environment variable.

Methodology

All JavaScript functions were tested in a sandbox Adobe Campaign instance by executing the code via the acc CLI, such as:

  • Global option testing, with oneliner acc instance exec -s <script>
acc instance exec -s "context.result = getOption('NmsEmail_DefaultFromAddr')"
# <context><result>[email protected]</result></context>

acc CLI used to execute 1 unit test on the Adobe Campaign instance

  • Unit tests, with acc instance exec -f <file>
acc instance exec -s "context.res1 = NL.assert(NL.isEmpty([]) === true);"

acc CLI used to execute many unit tests on the Adobe Campaign instance

AI-assistance

This πŸ“• AC JS Reference is one of the foundations of the AI Adobe Campaign development lifecycle (with AGENTS.md).

Bibliography

This πŸ“• AC JS Reference knowledge base was built with many iterations of β€œtest & learn”, as well as the resources from: