Skip to content
Documentation
Updated 3 minutes to read
Markdown

The startsWith function, one of the Logical functions in the Formula plugin for Search Field Expressions, returns true when the content starts with the expression (prefix).

Uppercase a customer name with toUpperCase, then check an order id prefix with startsWith, animated walkthrough (7.12)
Animated walkthrough: on the Order Received JSON of the Order-to-Cash demo, toUpperCase of jsonPath('$.customer.name', body) returns TAILSPIN TOYS. startsWith('ORD-', jsonPath('$.orderId', body)) returns true for ORD-10005. With the prefix 'INV-' there is no match, and the Test tab shows Processed with warning: The Expression yields no result.

startsWith('expression', content [, content ...] [, matchAllValues])
Parameter Required Description
'expression' ✅ Yes The prefix to look for, in single quotes, for example 'G'. It's case-sensitive: startsWith('g', body) on GMT gives no value.
content ✅ Yes The value or values to check: body, context, or another Formula function such as regex. When you give several content arguments, each of them must match.
matchAllValues ❌ No Unquoted true or false (default). Applies when one content argument returns several values: false means at least one value must match, true means every value must match. A quoted 'true' is not the flag; it is compared as text.
  • true when the content starts with the expression.
  • When it doesn't, there is no value: Test Expression shows Processed with warning: The Expression yields no result.
  • When one content argument returns several values, one matching value is enough, unless matchAllValues is true.

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

Message Body:

GMT
startsWith('G', body)
true

Test Expression with startsWith('G',body) on the message body GMT, returning true
The message body GMT starts with G, so startsWith returns true.

Message Context:

Key Value
id GMT
startsWith('G', context('id'))
true

Test Expression with startsWith('G', context('id')) on the context key id with value GMT, returning true
The context value of id is GMT, which starts with G, so startsWith returns true.

Example 3: Check values extracted by another function

Section titled “Example 3: Check values extracted by another function”

Message Body:

GMT UTC
startsWith('U', regex('GMT|UTC', body))
true

Test Expression with startsWith('U',regex('GMT|UTC',body)) on the message body GMT UTC, returning true
regex extracts GMT and UTC; UTC starts with U, and one match is enough, so startsWith returns true.

Example 4: Check several message context values

Section titled “Example 4: Check several message context values”

Message Context:

Key Value
id UMT
id1 UZZ
startsWith('U', context(regex('id.*')))
true

Test Expression with startsWith('U', context(regex('id.*'))) on the context keys id and id1, returning true
context(regex('id.*')) returns the values of both keys, UMT and UZZ; they start with U, so startsWith returns true.

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...