Formula - Length
Section titled “ Formula - Length”The length function, one of the Math functions in the Formula plugin for Search Field Expressions, returns the character count of each value in the content.

Animated walkthrough: on the JSON Order Received event of order ORD-10005 in the Order-to-Cash demo, length(jsonPath('$.customer.name', body)) returns 13 for Tailspin Toys, the space included. On the Message Context tab, length(context('OrderNumber')) returns 9 for ORD-10005.
Syntax
Section titled “ Syntax”length(content [, unique])Parameters
Section titled “Parameters”| Parameter | Required | Description |
|---|---|---|
content |
✅ Yes | The values to measure: body, context, or another Formula function such as xPath or jsonPath. |
unique |
❌ No | Unquoted true or false; default true for this function. false: a value that appears several times counts every time. true: identical values count once. Values are compared as text, so 100 and 100.00 are different values. A quoted 'true' is an error. |
Returns
Section titled “Returns”- One character count per value in
content; several input values give several counts (see Example 4). - To get a single number from several counts, wrap
lengthin max, min, sum, or avg (see max).
Quoting, nesting, and how content is resolved are described in the Formula language rules.
Examples
Section titled “ Examples”Example 1: Measure a city name in an XML order
Section titled “Example 1: Measure a city name in an XML order”Message Body:
<ns0:Orders xmlns:ns0="SupplyChain.Schemas/1.0"> <Order> <Id>1337</Id> <Amount>666</Amount> <City>New York</City> <Partner>QWNtZQ==</Partner> </Order></ns0:Orders>Formula
Section titled “Formula”length(xPath('Orders/Order/City', body))Result
Section titled “Result”8New York is eight characters long, including the space.

length measures the extracted text, not the XML element, so the tags don't count.
Example 2: Measure the message body
Section titled “Example 2: Measure the message body”Message Body:
NodiniteFormula
Section titled “Formula”length(body)Result
Section titled “Result”8
Nodinite has eight characters, so length returns 8.
Example 3: Measure a message context value
Section titled “Example 3: Measure a message context value”Message Context:
| Key | Value |
|---|---|
Correlation Id |
demo001 |
Header#Content-Type |
Application/XML |
Formula
Section titled “Formula”length(context('Correlation Id'))Result
Section titled “Result”7
Only the Correlation Id key is read; its value demo001 has seven characters.
Example 4: Measure each value extracted from JSON
Section titled “Example 4: Measure each value extracted from JSON”Message Body:
{a:[{b:'This'},{b:'is'},{b:'Formula Plugin'}]}Formula
Section titled “Formula”length(jsonPath('a[*].b', body), true)Result
Section titled “Result”4214
jsonPath extracts three values, and length returns one count for each: This (4), is (2), and Formula Plugin (14).