Parameters

name string Internal name (@name) of the xtk:option
value number|string|date Value (@longValue|@stringValue|@timeStampValue) of the xtk:option record

Examples

Usage: execute code in production only.

setOption("cusEnvironment", "production");
if (getOption("cusEnvironment") === "production") {
  // executed in production only
}

Usage: store credentials different between environments: staging VS production.

var endpoint = getOption("endpoint");
var apiKey = getOption("apiKey");
// call endpoint with API key

Compliant with the 12-factor: Config pattern.

See also

  • 📕 getOption - Helper to read an instance-specific setting from the xtk:option schema, useful for environment variable.
  • 📕 sqlSelect - Run a raw SQL SELECT and returns an XML collection. Prefer queryDef for higher abstraction.