- 3 minutes to read

Message Context Key Search Field Expression Plugin

The Message Context Key plugin returns the value of one context property of a Log Event, looked up by its exact key. There's no pattern and no parsing: the whole value becomes the Search Field value. Use it when a context property already holds exactly the value you want, such as an order number or a file name set by the sender.

  • ✅ Simplest way to read a context value: enter the key, get the value
  • ✅ Reads only the context properties; the message body is never read

When to use it

Message Context Key and the four RegEx plugins cover the combinations of where the text is and what part of it you want. For every plugin, see Choose a plugin.

Your data You want Use
One context value (you know the key) The value as it is, no pattern Message Context Key (this page)
One context value (you know the key) The whole match of a pattern RegEx on Message Context
One context value (you know the key) Only the part inside a capturing group ( ) RegEx on Message Context with capturing groups
XML stored in a context value An XPath result XPath on Message Context
Message body The whole match of a pattern RegEx
Message body Only the part inside a capturing group RegEx with capturing groups
Several keys that match a pattern Their values Formula with context(regex('…'))

Expression syntax

Select Message Context Key in the Expression Type list and enter the key in the Expression field.

Expression Type list with Message Context Key selected
The Message Context Key plugin in the Expression Type list.

  • The Expression is the key itself, not a pattern. Write it exactly as it's logged.
  • BizTalk context properties are logged as namespace#property, for example http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName.
  • Context properties and the reserved keys are described in Context Options. Properties that the ContextPropertiesFilters System Parameter removes aren't kept, so don't base a Search Field on them.
  • To test, add the key and its value on the Message Context tab of Test Expression. When the key is missing, the test reports a warning:

Test Expression result warning that the expression yielded no result
Test result when the key isn't among the context properties.

Configure and test the expression as described in Add or manage Search Field and Test Your Expression.

Examples

Example 1: Return the value of a custom context key

Input

Key Value
ProductOfTheYear Nodinite

Expression

ProductOfTheYear

Result

Nodinite

Test Expression for Message Context Key returning Nodinite from the ProductOfTheYear context key
Test Expression: the value of ProductOfTheYear from the Message Context tab.

Example 2: Return the full path of the file that BizTalk received

Input

Key Value
http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName C:\Integration\In\Orders\PO_4711.xml

Expression

http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName

Result

C:\Integration\In\Orders\PO_4711.xml

To keep only the file name PO_4711.xml, use RegEx on Message Context with ([^\\]+$).

Message Context Key test: the BizTalk ReceivedFileName key returns the full file path
The full namespace#property key returns the logged value as it is.

Next Steps