- 2 minutes to read

Formula - isnull

New 6.1

The isnull function, one of the Logical functions in the Formula plugin for Search Field Expressions, returns a default value when the content is null or empty, and the content itself otherwise.

Syntax

isnull(content, 'default')

Parameters

Parameter Required Description
content ✅ Yes The value to check, typically the result of another Formula function such as jsonPath or xPath, or body or context.
'default' ✅ Yes The text to return when content is null or empty, in single quotes.

Returns

  • The 'default' text when content is null or empty.
  • Otherwise the value of content, unchanged.

Quoting, nesting, and how content is resolved are described in the Formula language rules.

Examples

Example 1: Return the default when the value is null

Input

Message Body:

{ "name": null }

Formula

isnull(jsonPath('name', body), 'default')

Result

default

The name property is null, so isnull returns the default text.

Test Expression tab: isnull(jsonPath('name', body), 'default') on a JSON body where name is null returns default
jsonPath finds no value for the null property, so the fallback text is used.

Example 2: Return the value when it is present

Input

Message Body:

{ "name": "John Doe" }

Formula

isnull(jsonPath('name', body), 'default')

Result

John Doe

The name property has a value, so isnull returns it unchanged.

Test Expression tab: the same isnull formula on a JSON body where name is John Doe returns John Doe
Same formula as Example 1; with a value present, the default text is not used.

Next Steps