이 예제에서는 우선순위 필드 값에 따라 텍스트의 색상을 변경하도록 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?# #@EXPRESSION::if (#?State?# ne #%State%#) { "(Old Value: ". #%State%# .")"; }@#
필드 메타 태그가 EmailPlus 표현식에 사용될 수 있지만 간혹 표현식이 올바르게 평가되지 않을 수도 있습니다. 특히 필드 값에 큰따옴표 또는 작은따옴표의 홀수가 포함된 경우 표현식이 올바르게 평가되지 않습니다. 이 경우 필드 메타 태그를 사용하지 않고 EmailPlus 글로벌 스크립트에서 함수를 사용하여 필드 값을 해결합니다. 추가로 quotemeta Perl 함수를 사용하여 필드 값에 있는 비영숫자 문자를 이스케이프합니다. 이 함수를 사용하여 EmailPlus 표현식에서 필드 값을 효과적으로 비교할 수 있습니다. 다음 예제에서는 설명 필드의 필드 값을 설명 필드의 원래 필드 값과 비교합니다. 값이 다른 경우, EmailPlus 알림에 설명 필드가 변경되었음을 표시하는 메시지를 포함합니다.
#@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;
@#