EMP_EscapeHTML function

This function converts a string of HTML reserved characters to HTML code.

Synopsis

You can use the EMP_EscapeHTML function in expressions and custom meta tags. With this function, you can create expressions or custom meta tags that contain text that can be interpreted as HTML code (such as formatting), and text that should not be interpreted as HTML code (field values).
EMP_EscapeHTML($string)

Examples

This example shows output from an expression that contains HTML code that should be interpreted by the email client and field values that should not be interpreted as HTML code. The example generates a table of the new and old values of all fields that have been modified in a record, except the history field. The EMP_Verbatim function is called in the expression to disable the automatic HTML formatting of the output. The EMP_EscapeHTML function is called only to modify the field values that are in the table.
#@EXPRESSION::
EMP_Verbatim();
$table="";
$fieldsInfos = $entity->GetFieldsUpdatedThisEntireAction();
if ($fieldsInfos->Count() > 0) {
    $table .= "The following fields were modified : <BR>";
    $table .= "<TABLE>";
    $table .= "<TR><TH> Field </TH><TH> New Value </TH><TH> Old Value </TH></TR>";
    for (my $i=0; $i < $fieldsInfos->Count(); $i++) {
        $fieldInfo = $fieldsInfos->Item($i);
        $fieldName = $fieldInfo->GetName();
        next if (lc($fieldName) eq "history");

        $fieldValue = $entity->GetFieldValue($fieldName)->GetValue();
        $oldFieldValue = $entity->GetFieldOriginalValue($fieldName)->GetValue();

        $table .= 
"<TR><TD>".EMP_EscapeHTML($fieldName).":</TD><TD>".EMP_EscapeHTML($fieldValue)."</TD><TD>".EMP_EscapeHTML($oldFieldValue)."</TD></TR>";
    }
    $table .= "</TABLE>";
}
$table;
@# 

In this is example, the code segment can be inserted into the EMP_SubstituteCustomMetaTag function in the EMP_Customisable global script to create a new custom meta tag called #@FIELDSCHANGEDHTMLTABLE@#.

    elsif ($customTag eq "fieldschangedhtmltable") {
        if ($isTest) {
            $errorTags = "";
        }
        else {
            EMP_Verbatim();
            $table="";
            $fieldsInfos = $entity->GetFieldsUpdatedThisEntireAction();
            if ($fieldsInfos->Count() > 0) {
                $table .= "The following fields were modified : <BR>";
                $table .= "<TABLE>";
                $table .= "<TR><TH> Field </TH><TH> New Value </TH><TH> Old Value </TH></TR>";
                for (my $i=0; $i < $fieldsInfos->Count(); $i++) {
                    $fieldInfo = $fieldsInfos->Item($i);
                    $fieldName = $fieldInfo->GetName();
                    next if (lc($fieldName) eq "history");

                    $fieldValue = $entity->GetFieldValue($fieldName)->GetValue();
                    $oldFieldValue = $entity->GetFieldOriginalValue($fieldName)->GetValue();
                    $table .= "<TR><TD>".EMP_EscapeHTML($fieldName).":</TD><TD>".EMP_EscapeHTML($fieldValue)."</TD><TD>".EMP_EscapeHTML($oldFieldValue)."</TD></TR>";
                }
				
                $table .= "</TABLE>";
            }
			
        $fieldValue = $table;
        }
    }