Working with embedded field expressions in meta tags
You can embed current and previous field value tags in the expression tag itself. Be sure that the field values do not contain single or double quotes. If a field value contains an odd number of single or double quotes, the value might cause an expression error; then the EmailPlusTemplate template will not be validated correctly. This is a known limitation in the EmailPlus package.
A better approach is to use the EmailPlus functions to evaluate field values. If you compare field values, use the quotemeta() Perl function to escape any non-alphanumeric characters to ensure that the expression is evaluated correctly. For example, the following expression would be evaluated correctly if the field value does not contain single or double quotation marks:
#@expression::if (#?Description?# ne #%Description%#) { “Description field has changed\n”.#%Description%#; }@#
#@expression::if (quotemeta(Gfv(“Description”)) ne quotemeta(Gfov(“Description”))) { “Description field has changed\n”.Gfov(“Description”); }@#
As another example, assume that you intend to display the submit date from your defect record, but you do not want to use the default date format. Instead, you want to display the date in a different form. Here is a simple example expression using a meta tag:
#@expression::use Date::Format;use Date::Parse; ctime( str2time( #?SubmitDate?# ));@#
This is expanded to the following example. It is a syntactically valid expression. It returns a date object.
#@expression::use Date::Format;use Date::Parse; ctime( str2time( “2010-07-12 10:45:18” ));@#
When the expression is evaluated, it returns the following information that is substituted into the output message:
Mon Jul 12 10:45:18 2010
The following table lists the kinds of data types that are returned when an old field or current field value is expanded within a meta tag.
Field type | Returned expression |
---|---|
INT | An integer, for example, 54 |
DATE_TIME | A 24 hour date string in this format “YYYY-MM-DD hh:mm:ss”, for example “2012-10-20 15:23:04” |
SHORT_STRING, MULTILINE_STRING, ID, STATE, RECORDTYPE, DBID, REFERENCE and any other types not specified | A string value in double quotation marks, for example: "some text". Strings in double quotation marks that are embedded in the original field value are correctly handled to yield a syntactically correct string value. |
REFERENCE_LIST | A reference to an array of quoted values in double quotation marks, for example ["value 1", "value 2" ] |