Skip to content
Documentation
Updated 2 minutes to read
Markdown

The contextKey Formula function returns the key names (not the values) of the Message Context properties of the Log Event whose key matches a regular expression.

List the customer context keys of an order with contextKey, then count them, animated walkthrough (7.12)
Animated walkthrough: on the Message Context of the Order Received event of order ORD-10005 in the Order-to-Cash demo, contextKey(regex('^Customer')) returns the key names CustomerId and CustomerName, not their values. Nested in count, the same call returns 2.

contextKey(regex('Key pattern'))
Parameter Required Description
regex('Key pattern') Yes A regex that is matched against the context key names.

Every matching key name, one value per key. Duplicates are collapsed (see Formula language rules). When no key matches, nothing is returned. To get the values of the matching context keys instead, use context with the same regex(...) argument.

Example 1: List the order keys in the context

Section titled “Example 1: List the order keys in the context”
Key Value
Order#123 OK
Order#456 OK
Order#789 Fail
contextKey(regex('Order#.*'))
Order#123
Order#456
Order#789

Formula contextKey expression returning three Order key names from the Message Context tab (7.12)
Each key that matches Order#.* is returned as its own unique match.

  • contextKey returns the whole key name whenever the pattern matches part of it. The pattern matches anywhere in the key name unless you anchor it: use ^Order[#] to match only keys that start with Order#.
  • In Formula regular expressions # starts a comment, so 'Order#.*' in the example really runs as 'Order'. It works here because every key starts with Order; write [#] or \# when the # matters. See Formula language rules.
  • Combine with count to get the number of matching keys, for example count(contextKey(regex('Order#.*'))).

...

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...