次の例は、優先順位フィールドの値によってテキストの色を変更するための HTML コードを追加する方法を示します。優先順位の値が 1 の場合、テキストは赤で表示されます。
#@EXPRESSION::if ( #?Priority?# eq "1 - High" ) {"<FONT COLOR=¥"red¥">";} elsif ( #?Priority?# eq "2 - Medium" ) { "<FONT COLOR=¥"orange¥">";} elsif ( #?Priority?# eq "3 - Low" ) { "<FONT COLOR=¥"yellow¥">";}@#Priority: #?Priority?# </FONT>
次のコード例は、関連レコードのすべてのレコード ID をスペースで区切って同一行に表示します。 レコードに関連レコードが関連付けられていない場合は、何も表示されません。
#@EXPRESSION::if ( scalar( @{#?RelatedRecords?#} ) ) { "Related Records: ".join(" ",@{#?RelatedRecords?#}); } else { ""; }@#
次のコード例は、State フィールドの現行値を表示し、変更された場合は、State フィールドの前の値も表示します。
State: #?State?# #@EXPRESSION::if (#?State?# ne #%State%#) { "(Old Value: ". #%State%# .")"; }@#
EmailPlus 式でフィールド メタ タグを使用することができますが、式が正しく評価されない場合があります。 具体的には、フィールド値に奇数の二重または単一引用符が含まれていると、式は正しく評価されません。 この場合、フィールド メタ タグを使用するのではなく、EmailPlus グローバル スクリプト内の関数を使用してフィールド値を解決することができます。 さらに、quotemeta Perl 関数を使用して、フィールド値の非英数字の文字をエスケープします。 この関数を使用すると、EmailPlus 式のフィールド値を的確に比較できます。次の例は、Description フィールドのフィールド値と Description フィールドのオリジナルのフィールド値を比較します。 これらの値が異なる場合、EmailPlus 通知には Description フィールドが変更されたことを示すメッセージが組み込まれます。
#@EXPRESSION::if ( quotemeta(Gfv("Description")) ne quotemeta(Gfov("Description") ) { "The Description field has changed: “.Gfv(“Description") ; }@#
次の例は、レコード添付ファイルに関する詳細を通知に追加します。 追加される詳細に関する説明については、コード内のコメントを参照してください。
#@EXPRESSION::
# Get a list of the attachment fields in this record type...
my($AttachmentFields) = $entity->GetAttachmentFields();
# Tell how many attachment fields there are and show their
# names...
$M = $M . "This entity contains " . $AttachmentFields->Count() .
" attachment field(s)\n";
for ($A = 0; $A < $AttachmentFields->Count(); $A++)
{
$M = $M . " " . ($AttachmentFields->Item($A) )->GetFieldName() . "\n";
}
$M .= "\n";
# Iterate over the attachment fields; for each one, list the
# attachments it contains in the current record...
for (my($AF) = 0; $AF <$AttachmentFields->Count(); $AF++) {
my ($AttachmentField) = $AttachmentFields->Item($AF);
$M = $M ."Attachment field '"
. $AttachmentField->GetFieldName().
"' contains:\n";
# Iterate over the attachments in this field...
my($Attachments) = $AttachmentField->GetAttachments();
for (my($A) = 0; $A <$Attachments->Count(); $A++) {
my($Attachment) = $Attachments->Item($A);
# Report info about this attachment...
$M = $M .
" Filename='" . $Attachment->GetFileName() . "'" .
" FileSize=" . $Attachment->GetFileSize() .
" Description='" . $Attachment->GetDescription() . "'" .
"\n";
}
$M = $M ."Total attachments: ". $Attachments->Count() ."\n\n";
}
# Display the results...
$M;
@#