Skip to main content
Version: 4.13.3

Using simple expression language in Dovetail

Simple expression are supported by the following components:

  • Set Header
  • Set Headers
  • Filter
  • Content Router
  • Split

Frequently used headers

OccurrenceHeader nameExpression (example)
Sets full message body to a header of your choice[Random]${bodyAs(String)}
Adds an attachment to emailContent-Dispositionattachment;filename=text.csv
Specifies the content type of an xml messageContent-Typetext/xml
Specifies the content type of a json messageContent-Typetext/json or application/json
Specifies the content type of a well formed e-mail in HTML formatContent-Typetext/html
Specifies the content type of an e-mail in plain text formatContent-Typetext/plain
Specifies the filename with a timestamp of the message exportCamelFileNameproducts_${date:now:yyyyMMdd_HHmmssSS}.xml
Specifies the filename without the original extension of the message exportCamelFileNamejohn_${file:onlyname.noext}.jpg
Replaces a character range in a value of a header with another range[Random]${header.HeaderName.replaceAll("A","B")}
Adds a random number to the value of an existing header[Random]${header.CamelFileName}_${random(100)}
Adds a Europe/Amsterdam DateTimeNow to a header[Random]${date-with-timezone:now:Europe/Amsterdam:yyyy-MM-dd HH:mm:ss}
Determines the length of the message body[Random]${bodyAs(String).length}
Trims the value to remove leading and trailing whitespaces and line breaks[Random]${header.HeaderName.trim()}
Gets the error message of the exchange[Random]${exchangeProperty.CamelExceptionCaught.getMessage()}

Frequently used content filters

OccurrenceExpression (example)
Allows messages to pass through if the header contains a specific character range${header.HeaderName} contains "A"
Allows messages to pass through if the header contains the same specific character range as an other header has'${header.Authorization}' == '#{InboundAuthorizationCode}'
Allows messages to pass through if the length of the consumed file is larger than 0 kB${header.CamelFileLength} > 0
Allows messages to pass through if one header doesn't contain a specific character range and simultaneously another header doesn't contain a specific character range too${bodyAs(String)} not contains '"data":"UPDATE"' && ${bodyAs(String)} not contains '"data":"INSERT"'
Allows messages to pass through if a message header is empty.${header.abc} == ""
Allows messages to pass through if a message header is not empty.${header.abc} != ""
Allows messages to pass through if the body length is larger than 2 characters${bodyAs(String).length} > 2

Operator support

Things to keep in mind

  • To refer a header in the simple expression language use the notation as follows: ${header.headername}
  • Enclose a literal string in ' '
  • There must be spaces around the operator
  • Syntax: ${header} [operator] 'value'
  • Dovetail will automatically type convert the value type to the header type, so it is possible to for example, convert a string into a numeric so you can use --> comparison for numeric values
  • Keep in mind that simple headers are not case sensitive. When a header variable named errormessage is set at an earlier stage, a header variable set to ERRORMESSAGE will update the previously set header variable errormessage and will not create a new header variable.

Frequently used operators

OperatorDescription
==Equals
-->Greater than
=-->Greater than or equals
<Less than
<=Less than or equals
!=Not equals
containsFor testing if contains in a string based value
not containsFor testing if not contains in a string based value
regexFor matching against a given regular expression pattern defined as a String value
not regexFor not matching against a given regular expression pattern defined as a String value
&&The logical AND operator is used to group two expressions
||The logical OR operator is used to group two expressions

Share

Useful and original tips and tricks are always welcome. Inform us to share it with other users by using the form!