Skip to main content

OXL expressions and reference

OXL is the Owlie Expression Language. An OXL expression is one line that computes a value from the data it is given. Examples are a display name from a first and last name, a department code from a department, and a yes or no from a status. Owlie evaluates expressions wherever you configure a computed value, such as a sync attribute mapping, a provisioning attribute mapping, a bulk identity change or a reaction's condition.

An expression is not a program. It has no variables to assign, no loops and no statements, and it cannot call a network or change anything. It reads the values it is given and returns one result.

lower(identity.first_name + "." + identity.last_name) + "@acme.example"

For Mina Okafor, that expression gives mina.okafor@acme.example.

Try it​

Pick a sample identity and an expression. The results were produced by Owlie's own evaluator.

One expression, three identities
Sample identity
Expressionlower(identity.email)
ResultText
"mina.okafor@acme.example"Functions are called by name with their arguments.
The same expression for each sample identity
Mina Okafor"mina.okafor@acme.example"
Tomas Lindqvist"tomas.lindqvist@partner.example"
Priya Raman"priya.raman@acme.example"
identityEmployee, every field set
first_name
"Mina"
last_name
"Okafor"
preferred_name
null
email
"Mina.Okafor@acme.example"
department
"Finance"
location
"Lagos"
employee_type
"FULL_TIME"
tags
["finance-close"]
custom
{"badge_number":"B-4471"}
Every result here came from Owlie's evaluator, run on these sample identities. The same expression can be right for one person and wrong for the next: test with a record that has values missing.

The figure shows the two habits that prevent most mistakes. A value that can be missing has to be guarded, because a missing value joined to text is written as the word null. And everything is a function call or an operator: there are no methods, so lower(identity.email) works and identity.email.toLowerCase() does not.

Values​

WriteFor
"text" or 'text'A string. Escape the quote character inside it with a backslash: "say \"hi\"".
42, -7.5A number. Exponents (1e3) and a leading point (.5) are not accepted.
true, falseA boolean.
nullNo value.
["a", "b"]An array.
{ Finance: "FIN", "R&D": "RD" }An object. Quote a key that is not a plain name.

A string can hold expressions in ${...}. Each is evaluated and written into the text:

"${identity.first_name} ${identity.last_name} (${identity.employee_type})"

To use an inner string inside ${...}, switch quote type: 'Status: ${active ? "on" : "off"}'. Write \${ for a literal ${.

Reading values​

An expression reads the values Owlie hands it by name. Which names exist depends on where the expression runs: Where expressions run lists them.

WriteReads
identity.emailA property.
identity.custom.badge_numberA nested property.
identity["first_name"]A property by a computed name.
identity.tags[0]An array item by position, counting from 0.
split(identity.email, "@")[1]An item of a function's result.
accounts[.role == "admin"]The items of an array of objects that pass a test. Inside the brackets, .role is the item's own property.

Reading something that is not there does not fail. A name Owlie did not provide reads as null, and a property that does not exist reads as empty. Both count as missing for ??, coalesce and isEmpty.

A filter returns an array. Reading a property of that array gives the property of its first item, so accounts[.role == "admin"].name is the name of the first admin account. A filter works on arrays of up to 200 items.

Operators​

OperatorDoes
+Adds two numbers. If either side is text, joins them as text: "a" + 1 is "a1".
-, *, /Subtract, multiply, divide. Text that looks like a number is converted: "5" - 2 is 3.
//Divides and rounds down: 5 // 2 is 2.
%The remainder: 7 % 3 is 1.
^Raises to a power: 2 ^ 3 is 8.
==, !=Equal, not equal. Values of different types are converted first, so 1 == "1" is true. There is no === or !==.
<, <=, >, >=Compare numbers, or text in alphabetical order.
in"b" in "abc" tests whether text contains other text. "x" in ["x", "y"] tests whether an array holds a value, compared exactly: "2" in [1, 2] is false.
&&, ||And, or. They return one of their sides, not always a boolean: a || "default" gives a unless a is missing, empty, 0 or false.
??Gives the left side unless it is null or missing. Unlike ||, it keeps 0, false and "".
!Not.
a ? b : cb when a is true, otherwise c.
a ?: ca when a is true, otherwise c.

Operators bind in this order, tightest first. Use parentheses when in doubt.

  1. !
  2. %, ^
  3. *, /, //
  4. +, -
  5. ==, !=, <, <=, >, >=, in
  6. ??
  7. &&, ||
  8. ? :

A minus sign directly before a number makes it negative. To negate a value, subtract it from zero: write 0 - identity.offset, not -identity.offset.

Functions​

Call a function by its name with its arguments in parentheses. Functions are never called as methods of a value.

Text​

FunctionReturnsExample
lower(s), upper(s)The text in lower or upper case.lower("Mina") is "mina"
trim(s)The text without spaces at either end.trim(" a ") is "a"
startsWith(s, prefix)Whether the text starts with the prefix.startsWith("abc", "ab") is true
endsWith(s, suffix)Whether the text ends with the suffix.endsWith("abc", "bc") is true
contains(s, part)Whether the text contains the part. With an array, whether it holds the value.contains(identity.tags, "emea")
replace(s, search, replacement)The text with every occurrence of search replaced.replace("a-b-c", "-", ".") is "a.b.c"
split(s, delimiter)An array of the parts.split("a,b", ",") is ["a", "b"]
substring(s, start, end?)The characters from position start up to, not including, end. Positions count from 0.substring("abcdef", 1, 3) is "bc"

These functions convert what they are given to text first. A missing value becomes the text null, so upper(identity.title) is "NULL" for an identity with no title. Guard it: upper(coalesce(identity.title, "")).

Arrays​

FunctionReturnsExample
join(array, delimiter?)The items joined into text. The delimiter is a comma unless you give one.join(["a", "b"], " ") is "a b"
first(array), last(array)The first or last item, or empty for an empty array.first(["x", "y"]) is "x"
unique(array)The array without repeated values.unique(["a", "a"]) is ["a"]
flat(array)The array with one level of nested arrays opened up.flat([[1, 2], [3]]) is [1, 2, 3]
sort(array)The items in alphabetical order. Numbers sort as text: [1, 10, 9].sort(["b", "a"]) is ["a", "b"]
reverse(array)The items in reverse order.reverse([1, 2]) is [2, 1]

Given something that is not an array, join returns "", first and last return empty, and the others return [].

Conversion and tests​

FunctionReturnsExample
string(v)The value as text. A missing value becomes "".string(12) is "12"
number(v)The value as a number.number("12") + 1 is 13
bool(v)false for a missing value, 0, "" and false. true for anything else, including the text "false".bool("") is false
typeOf(v)"string", "number", "boolean", "array", "object", "null" or "undefined".typeOf(identity.tags) is "array"
coalesce(a, b, ...)The first argument that is not missing.coalesce(null, "x") is "x"
isEmpty(v)true for a missing value, "", [] and {}. 0 and false are not empty.isEmpty("") is true
length(v)The number of characters, items or keys. 0 for anything else.length("abc") is 3

Objects and lookups​

FunctionReturns
keys(object), values(object)An array of the object's keys or values.
lookup(value, mapping, default?)The mapping's entry for value. When there is none, or value is missing, the default. Without a default, null.

lookup is how you translate one vocabulary into another:

lookup(status, { "Active": "ACTIVE", "On Leave": "LEAVE", "Inactive": "TERMINATED" }, null)

Generated values​

FunctionReturns
now()The current time as a number of milliseconds since 1970.
password(length?), genPassword(length?)A random password with lower-case and upper-case letters, digits and symbols. 16 characters unless you give a length, from 4 to 1,024.
faker(method, ...args)A random sample value, for test data. Methods: person.firstName, person.lastName, person.jobTitle, company.name, location.city, location.countryCode, datatype.boolean, number.int (with a minimum and a maximum), helpers.arrayElement (with an array) and date.between.
relatedAccount(identityId, attribute)The value of an attribute on the account another identity has on the same resource, or null when there is none. Available in provisioning attribute mappings only.

These give a different result each time they run, so some places refuse them: Where expressions run says which.

Where expressions run​

The syntax and the functions are the same everywhere. What differs is the names an expression can read, and a few limits.

WhereAn expression readsDetails
Sync attribute mappingsThe source record's own fields, by name: jobTitle, name.givenName.Attribute mappings with OXL
Provisioning attribute mappingsidentity, roles, groups, formData, config, this, generated, resource and operation.Attribute mappings and continuous updates
Provisioning hook parametersidentity, resource, operation, and account with its identifiers, attributes and lifecycleState.Hooks and delayed operations
Bulk identity changesidentity, as it was before the job's changes.Select and update identities in bulk
Reaction conditionsevent, identity, and the fields of the event: for an identity event, changed_keys, identity_changes_old and identity_changes_new. The condition holds only when the result is exactly true.Lifecycle reactions
Identity import mappingsThe file's columns, by name. now, password, genPassword and relatedAccount are refused, because an import's preview has to match what the import writes.Identities
Custom connector manifests and definitionsDepends on the field: config, credentials, identity and others.Connector expressions

identity has the same attributes wherever it appears: identity.email, identity.first_name, identity.department, identity.manager_id, identity.lifecycle_state, identity.tags, and your custom attributes under identity.custom. Any of them can be missing.

Test an expression​

Fields that take an expression have a button that opens the full expression editor. In it:

  1. Write the expression under Expression. The editor completes function names and the fields you can read.
  2. Check Test Context. It holds the sample values, as JSON, that the expression will read. Edit them to try other cases, such as a missing department. Reset restores the sample.
  3. Select Run. The value appears beside Result, or the problem beside Error.
  4. Select Apply expression to put the expression in the field. Nothing is saved until you apply it and save the form you came from.

Run evaluates the expression against the test context only. It cannot look anything up, so relatedAccount reports that it is unavailable there. To check a provisioning mapping against a real person, use the profile's preview, described in Configure a provisioning profile.

Try the cases that break expressions: a missing value, an empty list, a value in an unexpected case or with spaces around it.

Errors​

An expression can fail in two ways.

It can fail to parse. Owlie reports where:

Invalid expression token: = (line 1, col 23)

That message comes from identity.department === "Finance": OXL reads ==, then finds a = it has no use for. Other common causes are a missing operator between two values, an unclosed quote or bracket, and a method call.

Or it can parse and fail when it runs, for example by calling a function that does not exist:

toLowerCase is not defined.

A missing value is not an error. It flows through the expression as null, which is how the word null ends up in a display name. What a failed expression does to the operation around it depends on where it runs, and the page for each place says. A provisioning mapping that fails, for example, stops the operation until you fix the expression and retry.

Limits​

Owlie bounds every expression so that one cannot run away:

LimitValue
Expression length2,000 characters
Nesting depth, including parentheses20 levels
Size, counted in parsed parts200
Running time500 milliseconds
Text an expression can build65,536 characters
Array an expression can build10,000 items
Array a filter can test200 items
Keys in an object written in an expression1,000

Three places set their own bounds. Sync and identity import mappings allow 2,048 characters, and sync mappings 5 seconds. Bulk identity changes allow 4,096 characters, 40 levels and 400 parts, with 100 milliseconds for each identity.

An expression over a limit is refused when you save it or when it runs, with a message that names the limit. If a mapping needs more than an expression can hold, split it across hidden fields in a provisioning profile, or compute the value in the source system.