(new in 13.0.0)
The compare_extended_field() command compares a given value with the content of an Extended Field, and vice versa.
The command compares the value (Default Value) of the given Extended Field Name (extended-field-name) with the help of a comparison operator (operator) with the given value (value).
Structure of the command
compare_extended_field('extended-field-name','operator','value');
Return value
positive |
if the condition is met |
negative |
if the condition is not met |
Parameters
extended-field-name
Name of the Extended Field.
operator
The operators depend on the data type (Type) of the corresponding Extended Field(String, Time, Integer, Hex, Boolean, Number), where in general every expression works for every data type
Possible values:
Operator |
Description |
|||
---|---|---|---|---|
=~ |
== |
eq |
is |
compares for equality / conformity |
!~ |
!= |
ne |
is not |
compares for inequality / nonconformity |
< |
lt |
smaller |
||
> |
gt |
larger |
||
<= |
le |
smaller than or equal to |
||
>0 |
ge |
larger than or equal to |
In the comparison operation, the sender email address is always used for outgoing emails in order to determine the Extended Field of the respective Managed Domain.
In case of incoming mails, the recipient email address is always used. If the incoming email contains recipients from various Managed Domains, the email is splitted. The comparison then is performed with the Extended Field of the respective Managed Domain.
Only in internal emails (see internal()), it can be defined by adding a
:s
that the Extended Field of the sender, or by adding
:r
the one of the recipient should be considered.
For the data type (Type) "String", the comparison can be reversed. This means that not the content of extended-field-name is compared with the content of value, but that the content of value is compared with the content of extended-field-name.
For this, the comparison operator ":1" is to be added.
If the Extended Field contains a Regular Expression, this can be used as equality pattern.
value
Returns the comparison value, or when using ":1", the value to be compared. Here, variables are allowed.
Example 1
Line |
Code |
---|---|
01 |
if (compare_extended_field('my-extended-field','=~:1','$subject')) { |
02 |
log(1,'The subject contains a five digit word, beginning with "b" and ending with"d"'); |
03 |
} |
Explanation
Assuming my-extended-field has the content "(?i)(b...d)", which is a regular expression that describes all words with five characters (case insensitive) that start with "b" and end with "d".
The content of value is the content of the variable $subject, that is the email subject. In this example, this should be "The person is blind".
In line 01, due to ":1" in the operator =~ , not the content of the Extended Field (my-extended-field) is compared for equality with the value ($subject), but the value ($subject) is compared with the content of the Extended Field (my-extended-field).
As the subject ($subject) "The person is blind" contains the word "blind", a word with five letters that starts with "b" and ends with "d" and therefore matches the regular expression "(?i)(b...d)" from the Extended Field (my-extended-field), this statement would be true. Therefore the log message from line 02 would be written.