Code Processor Functions

What It Is

Jetstack's code processor is the function library behind {=...} expressions. These functions let expressions do more than interpolate values. They can cast values, reshape arrays, read query results, inspect changes, build links, and access runtime providers such as trigger parameters or secrets.

Why It Matters

Many important configuration points in Jetstack rely on these functions:

  • property conditions
  • default values and calculations
  • query parameter defaults
  • automation branching and payload construction
  • canvas item configuration
  • integration helpers

If you know what the function set actually exposes, you can write shorter and much more reliable expressions.

Scope Of This Page

This page documents the functions registered in CodeProcessorProvider::getProcessor() and focuses on:

  • the callable name used inside expressions
  • the purpose of the function
  • its parameters
  • its return value

Per your requested scope, this page intentionally skips every function whose name starts with date_*.

The older date helpers that do not start with date_*, such as date, today, time, strtotime, dateDiff, formatDate, and compareDates, are still covered below because they remain part of the expression API.

Availability Model

Not every function is available in every expression runtime.

AvailabilityMeaning
AlwaysRegistered in every code processor instance.
ContextRegistered only when the processor has an ActiveResource context.
TriggerRegistered only when a trigger-parameters provider is present.
EndpointRegistered only when a previous-endpoint provider is present.
Global varsRegistered only when a global-variable provider is present.
Local varsRegistered only when a local-variable provider is present.
App paramsRegistered only when an app-parameter provider is present.
SecretsRegistered only when a secrets provider is present.
DataQuery provider requiredThe function is registered, but it only works when a current DataQuery provider exists.

Function Catalog

Basic And Casting

FunctionAvailabilityPurposeParametersReturns
get(value)AlwaysReturns the provided value unchanged.value: any input.mixed
getRaw(value)AlwaysLow-level helper that marks a property lookup for raw-value resolution.value: usually a property key or path component.mixed marker value used by the resolver
transformLiteral(value, literal)AlwaysIgnores the first argument and returns the literal second argument unchanged.value: any input, literal: the value to return.mixed
setVar(name, value)AlwaysStores a processor variable and returns the stored value.name: string variable name, value: any value.mixed
toBool(value)AlwaysCasts a value to boolean.value: any value.boolean
toString(value)AlwaysCasts a value to string. DateTimeInterface values are formatted as ISO 8601 with offset (e.g. 2026-05-26T14:44:26+02:00), so timezone information is preserved instead of being lost.value: any value.string
toInt(value)AlwaysCasts a value to integer.value: any value.int
toFloat(value)AlwaysCasts a value to float.value: any value.float
toArray(value)AlwaysCasts a value to array.value: any value.array
toObject(value)AlwaysCasts a value to stdClass.value: any value.stdClass

Collections And Reshaping

FunctionAvailabilityPurposeParametersReturns
map(iterable, transform = "")AlwaysTransforms iterable items using a dot-chain or a mapping object. In chain mode, each step resolves a property or calls a transform function. In mapping mode, each output field gets its own transform chain.iterable: any iterable value. transform: string chain such as owner.full_name, or an array/object map such as { "name": "owner.full_name", "status": "status.upper()" }.array
range(start, end, step = 1)AlwaysBuilds a numeric or string range.start: string, int, or float. end: string, int, or float. step: int or float.array
in_array(needle, haystack)AlwaysChecks whether a value exists in an array.needle: any value. haystack: array.boolean
concat(array)AlwaysJoins array items into one string without a separator.array: array of strings.string
join(separator, array)AlwaysJoins array items with a separator.separator: string. array: array of strings.string
arrayKeys(array)AlwaysReturns the keys of an array.array: array.array
arrayValues(array)AlwaysReturns the values of an array.array: array.array
arrayFirstValue(array)AlwaysReturns the first value from an array.array: array.mixed
arrayLastValue(array)AlwaysReturns the last value from an array.array: array.mixed
arrayShift(array)AlwaysRemoves and returns the first value.array: array.mixed
arrayPop(array)AlwaysRemoves and returns the last value.array: array.mixed
arrayShiftGetArray(array)AlwaysRemoves the first value and returns the remaining array.array: array.array
arrayPopGetArray(array)AlwaysRemoves the last value and returns the remaining array.array: array.array
arrayPush(array, ...values)AlwaysAppends one or more values to the end of the array.array: array. values: variadic values to append.array
arrayUnshift(array, ...values)AlwaysPrepends one or more values to the start of the array.array: array. values: variadic values to prepend.array
arrayGetKey(array, key)AlwaysReturns a value by key from an array.array: array. key: string or number.`mixed
length(value)AlwaysReturns string length for scalar values or item count for countable values.value: any value.number

Strings And Text Processing

FunctionAvailabilityPurposeParametersReturns
explode(separator, string, limit = PHP_INT_MAX)AlwaysSplits a string by a separator.separator: string. string: string to split. limit: numeric split limit.string[]
trim(string)AlwaysTrims leading and trailing whitespace.string: input string.string
removeHtmlTags(string)AlwaysRemoves HTML tags from text.string: input string.string
upper(string)AlwaysConverts a string to uppercase.string: input string.string
lower(string)AlwaysConverts a string to lowercase.string: input string.string
firstUpper(string)AlwaysUppercases the first character.string: input string.string
firstLower(string)AlwaysLowercases the first character.string: input string.string
webalize(string)AlwaysConverts text into a URL-safe or slug-like form.string: input string.string
firstNChars(text, count)AlwaysReturns the first N characters of a string.text: string. count: number of characters.string
lastNChars(text, count)AlwaysReturns the last N characters of a string.text: string. count: number of characters.string
startsWith(text, search)AlwaysChecks whether text starts with a substring.text: string. search: string prefix.boolean
endsWith(text, search)AlwaysChecks whether text ends with a substring.text: string. search: string suffix.boolean
contains(haystack, needle)AlwaysChecks whether a string contains a substring or whether an array contains a value. It also supports arrays of ActiveResource values and can match by object ID or code property.haystack: string or array. needle: any value.boolean

Hashing, Encoding, And Randomness

FunctionAvailabilityPurposeParametersReturns
md5(string)AlwaysReturns the MD5 hash of a string.string: input string.string
sha1(string)AlwaysReturns the SHA1 hash of a string.string: input string.string
sha256(string)AlwaysReturns the SHA256 hash of a string.string: input string.string
base64_encode(string)AlwaysBase64-encodes a string.string: input string.string
base64_decode(string)AlwaysBase64-decodes a string.string: encoded string.string
random(length = 10, chars = "0-9a-z")AlwaysGenerates a random string.length: desired length. chars: character pattern.string

Date And Time Helpers Not Starting With date_*

FunctionAvailabilityPurposeParametersReturns
date(format = "Y-m-d H:i:s", timestampOrDate = null)AlwaysFormats the current time or a provided timestamp/date string using PHP date(). If the second argument is a non-numeric string, it is parsed through strtotime().format: date format string. timestampOrDate: Unix timestamp, parseable date string, or null.string
today()AlwaysReturns today's date at 23:59:59.None.string
time()AlwaysReturns the current Unix timestamp.None.int
strtotime(dateTime = "now", baseTimestamp = null)AlwaysParses a date/time string into a Unix timestamp.dateTime: parseable date string. baseTimestamp: optional base timestamp.`int
dateDiff(date1, date2, absolute = false)AlwaysReturns a PHP DateInterval between two dates. Accepts strings, timestamps, or DateTimeInterface values.date1: first date. date2: second date. absolute: whether to force an absolute difference.DateInterval
formatDate(date, format)AlwaysFormats a date using a format string. Accepts strings, timestamps, or DateTimeInterface.date: date value. format: format string.string
compareDates(date1, operator, date2 = "now")AlwaysCompares two dates. Supports operators >, >=, <, <=, ==, within, withinMonth, and withinYear.date1: date string or timestamp. operator: comparison operator. date2: second date or reference date.boolean
toUtc(input, format = "Y-m-d H:i:s", sourceTz = null)AlwaysConverts a wall-clock value into a UTC datetime string. Use this when handing user input to query() or other SQL comparisons. ISO 8601 strings with explicit offsets are honored; naive strings are interpreted in the user's display timezone unless sourceTz overrides. The default format omits the offset because MySQL DATETIME parameters do not officially support ISO 8601 offsets and UTC is implicit by definition.input: any date/datetime value. format: output format string. sourceTz: optional source timezone for naive inputs.`string
fromUtc(input, format = "c", targetTz = null)AlwaysReverse of toUtc(). Converts a UTC value into a formatted wall-clock string in the user's display timezone (or targetTz if given). The default format is ISO 8601 with offset (e.g. 2026-05-26T14:44:26+02:00), so the timezone survives JSON serialization and parses cleanly in every client. Use this when rendering stored UTC values back to the user.input: any UTC date/datetime value. format: output format string. targetTz: optional target timezone.`string

ActiveResource And Change Tracking

FunctionAvailabilityPurposeParametersReturns
getTitle(activeResource = null)AlwaysReturns the title property value of an ActiveResource.activeResource: ActiveResource or null.`string
export(activeResource = null, properties = null, useSystemNames = true)AlwaysExports raw data from an ActiveResource, optionally filtered to selected properties and optionally using system names.activeResource: ActiveResource or null. properties: array of property names/system names or null. useSystemNames: whether to export using system names.`array
hasChanged(changes, property = null)AlwaysChecks whether a property changed. In trigger-aware flows, you can call hasChanged("status") and it will read the current changes object from trigger parameters.changes: either an ARChanges object or a property name. property: explicit property name when changes is passed explicitly.`boolean
isOnlyChange(changes, property = null)AlwaysChecks whether only one specific property changed. Like hasChanged, it also supports shorthand trigger usage.changes: ARChanges or property name. property: explicit property when changes is provided directly.`boolean
changedFrom(changes, property, previousValue = null, strict = false)AlwaysChecks whether a property changed from a specific previous value. In trigger shorthand, call changedFrom("status", "draft", true) and the function will resolve the trigger changes object automatically.changes: ARChanges or property name in shorthand mode. property: property name or previous value in shorthand mode. previousValue: expected old value. strict: strict comparison flag.`boolean

Files And Payload Construction

FunctionAvailabilityPurposeParametersReturns
fileFromFile(filename, title = null)AlwaysCreates a SimpleFile from a filesystem path. If no title is given, the basename of the file is used.filename: full or relative file path. title: optional title shown for the file.SimpleFile
fileFromData(data, title)AlwaysCreates a SimpleFile from raw data in memory.data: raw file contents. title: resulting file title/name.SimpleFile
if(condition, ifTrue, ifFalse)AlwaysTernary-style helper. The exported function name is if, even though the internal method is ifElse.condition: any truthy/falsy value. ifTrue: value returned when truthy. ifFalse: value returned when falsy.mixed
merge(...args)AlwaysMerges arrays and objects into one object. Objects are converted to arrays of properties first. Non-array, non-object arguments are ignored.args: variadic arrays or objects.object
object(...args)AlwaysBuilds one object by array_merge(...$args) and then converts the result to an object.args: variadic array fragments.object
objectRaw(...pairs)AlwaysCreates an object from a list of single-key arrays.pairs: arrays such as {"status":"open"} or {"owner":123}.object
randomFromList(list)AlwaysReturns a random item from an array, object property set, or traversable.list: array, object, or traversable.`mixed
jsonEncode(data)AlwaysJSON-encodes a value.data: any value.string
jsonDecode(json)AlwaysDecodes a JSON string.json: JSON string.mixed
toApiArray(object)AlwaysConverts an object into an API-style array. For ActiveResource, it uses API processing; for files, it uses file API serialization; otherwise it casts to array.object: ActiveResource, File, or another object-like value.array

DataQuery Helpers

FunctionAvailabilityPurposeParametersReturns
getDataQuery()DataQuery provider requiredReturns the current DataQuery instance.None.mixed
dataQueryFetch(property = null)DataQuery provider requiredFetches one value from the current DataQuery.property: optional property path/name.`mixed
dataQueryFetchObject()DataQuery provider requiredFetches one object from the current DataQuery.None.`object
dataQueryFetchAll(path = null)DataQuery provider requiredFetches all results from the current DataQuery.path: optional result path or property path.`array
dataQueryCount()DataQuery provider requiredCounts rows in the current DataQuery.None.`int
dataQueryMin(property)DataQuery provider requiredReturns the minimum value for a property over the current DataQuery.property: property name/path.`mixed
dataQueryMax(property)DataQuery provider requiredReturns the maximum value for a property over the current DataQuery.property: property name/path.`mixed

Internal Query Helpers

These are available only when the processor has an ActiveResource context.

FunctionAvailabilityPurposeParametersReturns
query(query, params = [])ContextRuns an internal API query by name.query: query identifier. params: associative array of query parameters.SoopioResultSet
queryCount(resultSet)ContextReturns the count of a query result set.resultSet: SoopioResultSet.int
queryFetchRow(resultSet, property = null)ContextFetches a single row or one property from a row.resultSet: SoopioResultSet. property: optional property name.mixed
queryFetchObject(resultSet, cache = true)ContextFetches one object from a query result set.resultSet: SoopioResultSet. cache: cache flag for object fetch.`object
queryFetchRows(resultSet, path = null)ContextFetches all rows from a query result set.resultSet: SoopioResultSet. path: optional path selection.array
queryFetchObjects(resultSet)ContextFetches all objects from a query result set.resultSet: SoopioResultSet.array

These are also available only when the processor has an ActiveResource context.

FunctionAvailabilityPurposeParametersReturns
currentLink()ContextReturns the current action link string, not a full absolute URL.None.string
user(property = null)ContextReturns the current user ActiveResource, or one property from that user.property: optional property name.`ActiveResource
resource(type, idOrData)ContextResolves an ActiveResource of the given type from an ID or inline data.type: target type name. idOrData: scalar ID/code, array, stdClass, or ArrayHash.`ActiveResource
objectShowLink(activeResource = null)ContextReturns the full show URL for an ActiveResource. Returns an empty string if no valid resource is passed.activeResource: ActiveResource or null.string
objectEditLink(activeResource = null)ContextReturns the full edit URL for an ActiveResource. Returns an empty string if no valid resource is passed.activeResource: ActiveResource or null.string
objectCopyLink(activeResource = null)ContextReturns the full copy URL for an ActiveResource. Returns an empty string if no valid resource is passed.activeResource: ActiveResource or null.string
objectCreateLink(activeResource = null)ContextReturns the full create URL for an ActiveResource. Returns an empty string if no valid resource is passed.activeResource: ActiveResource or null.string
objectDeleteLink(activeResource = null)ContextReturns the full delete URL for an ActiveResource. Returns an empty string if no valid resource is passed.activeResource: ActiveResource or null.string
objectActionLink(activeResource = null, action = null, args = [])ContextReturns the full URL for a named object action. Returns an empty string if either the resource or action is missing.activeResource: ActiveResource or null. action: action name. args: optional action arguments as an array.string
isLoginAs()ContextReturns whether the current user is operating through a shadow-login session.None.boolean
isApiRequest()ContextReturns whether the current request is being handled as an API call rather than a user-facing page. Useful when an expression should branch between human-facing output and machine-facing payloads (for example, omitting decorative fields from API responses).None.boolean

Runtime Parameter Helpers

FunctionAvailabilityPurposeParametersReturns
trigger(name)TriggerReturns a trigger parameter by name. Commonly used in automations and change-driven flows.name: trigger parameter name.mixed
endpoint(name)EndpointReturns a parameter from the previous endpoint context.name: parameter name.mixed
templateVar(name)Template varsReturns a variable from the focus page template.name: variable name.mixed
var(name)Local varsReturns a local variable. The exported function name is var, backed by the internal method localVar.name: variable name.mixed
env(name)Env varsReturns an environment variable from app settings. Returns null for unknown names (reserved Config keys do not bleed through).name: environment variable name.mixed
appParameter(name)App paramsReturns an app parameter by name.name: parameter name.mixed
selection()App paramsShortcut for the app parameter named selection.None.mixed

Secrets

FunctionAvailabilityPurposeParametersReturns
getSecret(name)SecretsReads a secret value from the secret store.name: secret name.mixed
saveSecret(name, value, title = "", type = "string")SecretsSaves or updates a secret value.name: secret name. value: secret value. title: human-readable label. type: secret type.mixed
removeSecret(name)SecretsDeletes a secret from the secret store.name: secret name.mixed

Notes On Practical Use

Functions With Aliased Export Names

These are the names you actually call in expressions:

  • use if(...), not ifElse(...)
  • use object(...), not objectMerge(...)
  • use var(...), not localVar(...)

Functions That Depend On Runtime Providers

Some functions look universal in the catalog, but they only work when their provider exists:

  • query*, currentLink, user, resource, and object*Link require a current ActiveResource context
  • trigger requires trigger parameters
  • endpoint requires a previous-endpoint provider
  • templateVar, var, and env require their respective variable providers
  • appParameter and selection require app-parameter access
  • getSecret, saveSecret, and removeSecret require the secret-store provider
  • getDataQuery and the dataQuery* helpers require a current DataQuery provider

Functions Worth Using Carefully

  • getRaw() is a low-level helper. It is useful when you intentionally need raw property values rather than the standard resolved value flow.
  • map() is powerful, but it becomes hard to maintain when the transform chain tries to do too much in one expression.
  • query() is convenient, but repeated query calls inside expressions can make configuration harder to reason about. Prefer explicit queries and typed configuration when possible.
  • Secret functions are operationally powerful and should be used deliberately. See Secret Store.