Using Expressions in Event Action Parameters
Many,but not all, event action parameters allow you to use expressions, rather than literal values, to specify the values of parameters. You typically do this when you want to allow for variable or dynamic values to be used for these values.
For example, you might want to specify a group of recipients to receive various notifications and prompt messages, and that group membership changes often. You can create a global constant value for the group and then use that global constant whenever you want a message sent to that group. Then, when the group membership changes, you can change it in one place (the global constant) and all event handlers that use that global constant automatically pick up the change.
Syntax for Expressions
Use quotation marks to indicate a literal string value For numbers, dates, or Boolean values (TRUE/FALSE), quotation marks are not required or allowed.
Consider these examples:
- CONDITION( "CreditLimit" < "500000" )
Both sides of the comparison are recognized as literal string values and treats them accordingly when executing the event action. The values are compared alphabetically as strings. Therefore, this condition results in a false result, because "C" sorts higher than "5" in the Unicode collation.
- CONDITION( CreditLimit < 500000 )
A syntax error is returned, because CreditLimit is not recognized as a valid function.
- CONDITION( P( "CreditLimit" ) > "500000"
)
Both sides of the comparison are valid, but again, the numeric value 500000 is treated as a literal string and compared with the value of the Credit Limit field that is returned. Property values are typeless, so the operation of the comparison depends on the expression on the other side. In this case, "500000" is a literal string value (as indicated by the quotation marks), so the property value is compared to it alphabetically as a string and may or may not return a valid result.
- CONDITION( E(MG_CurrentSite) IN ("MI";"ZZ"))
The MG_CurrentSite parameter is set for all running events. It is used to make it easier for event actions to exit processing based on the value of the current site. A finish action can be used to make a handler only operate for certain sites.
- CONDITION( P( "CreditLimit" ) > 500000 )
The current value of the CreditLimit property is used, but this time it is compared mathematically as a numeric value to the numeric constant 500000. If the property value cannot be converted numerically (for example, if it contains non-digit characters), a runtime error occurs.
For more information about expressions and the functions used to build them, see "Expression Functions" in the Guide to the Application Event System.