Creation of the custom email template
Template Structure
Database Monitor email templates have a structure that should be understood. The template is modular, enabling you to place sections of the email in any order you wish.
The Database Monitor email template will always start with header information. The header section contains the basic HTML beginnings, such as the <HTML> and <HEAD></HEAD> tags.
Following the header section, you may place any of the following sections in any order:
You may also use any of these sections more than once in a single template. The only section that has an ending tag is the PriorSigs section. All other sections are ended by the beginning of a new section.
To specify a new section, you will insert a tag into the HTML. Tags for each section are:
Again, PriorSigs is the only section that requires a closing tag. This is because the entire section must be loaded into memory and processed repeatedly for each signature.
For sample sections, see the example template at the end of this document.
REPLACEMENT VALUES
Note: All of the replacement values are case-sensitive. For instance, FIELDDATA and FieldData are not the same. If you use FieldData instead of FIELDDATA when trying to specifically place a field's value, the replacement will not take place.
Specifying Reason Code List to Use
We allow for the specifying of the reason code list to use from within the HTML. To insert a reason code list, you must have started a selection box. The one Option for the select box will have a value of “&reason”.
Example:
<select name="reason" size="1"> <option value="&reason">APP</option> </select>
In the above example, the <option></option> tags will be repeated for each entry in the CHGREASON code table entry. CHGREASON is the default reason code list. You may add new codes to this list or remove codes you do not need.
You may specify a custom reason code list using very similar syntax. To insert a custom reason code list, you will use the syntax “&reasons/RSNCDELIST”, where RSNCDELIST is the name of the code table where your custom reason codes are configured.
Example:
<select name="reason" size="1"> <option value="&reasons/PMRSN">APP</option> </select>
In the above example, Database Monitor will repeat the <option></option> tags, replacing the values with the individual codes found in the PMRSN code table entry.
Specifically Placing Field Values
There may be cases where the user may want to create a template that will allow for the specific placing of field data at certain places in the email. For instance:
Dear Frank,
Our records show that your credit limit has been increased from $10,000 to $20,000.
Regards,
ABC Inc. Accounting Department
Database Monitor allows for placement of data using the following syntax:
@@FIELDDATA:FLDNAME[B](1:10):J@@
The keyword @@FIELDDATA will denote that we are placing field data at this location. The trailing @@ denotes the end of the replacement value.
The keyword FLDNAME specifies the field name to look to for data. If the field name is followed by [B] DataThead will use the before image of the field. If the field name is followed by [A] or no square brackets, Database Monitor will use the after image. The specifications in parentheses allows for substringing of the field data, in this instance, start at position 1 for 10 characters. The final keyword allows us to specify a formatting variable. If FLDNAME were a numeric field, it would be formatted with the J format type.
Using this syntax, the template for the above email would look like this:
Dear @@FIELDDATA:CSNAME@@ ,
Our records show that your credit limit has been increased from @@FIELDDATA:CSCRLMT[B]:J@@ to @@FIELDDATA:CSCRLMT[A]:J@@ .
Regards,
ABC Inc. Accounting Department
Conditional Inclusion of Field
There may be cases where you may want to tailor the content based on the value of a field or fields. To facilitate this, Database Monitor allows for conditional expressions (IF statement blocks) in the HTML template.
Syntax for the IF statements is:
&IF:FLDNAME:B=VALUE
Where:
The end of the IF block is denoted by:
If the value requested for the field denoted by FLDNAME is equal to the value defined by VALUE, everything between the &IF and &ENDIF statements will be included. If the values do not match, nothing between the &IF and &ENDIF statements will be included.
Nested IF statements are not supported.
DISPLAYING PRIOR SIGNATURES
There may be cases where the addressee needs knowledge of prior signatures on the transaction. Database Monitor allows for inclusion of the prior signatures as follows:
<Table>
<TR>
<TD>Sig User</TD>
<TD>Sig Reason</TD>
<TD>Sig Comment</TD>
<TD>Sig Date</TD>
<TD>Sig Time</TD>
</TR>
&PRIORSIGS
<TR>
<TD>&SIGUSR</TD>
<TD>&SIGRSN</TD>
<TD>&SIGCMNT</TD>
<TD>&SIGDT</TD>
<TD>&SIGTIM</TD>
</TR>
&ENDPRIORSIGS
</Table>
A block of template code will be defined between the tags &PRIORSIGS and &ENDPRIORSIGS that will be repeated for each signature. In the example above, a table is created, headings are written, then the detail rows are generated for each of the prior signatures. The replacement variables needed to output a prior signature are:
All of the above replacement variables are voluntary, and they may be placed between the PriorSigs tags in whatever order you wish.
Calling a Program to Insert Data
You may wish to call a program to find some data to insert into the template. Database Monitor allows for this by using the &CallPgm tag. The requirements are:
The program must reside in the DATATHREAD library.
The program must accept two parameters:
Transaction ID (15,0 packed)
Return Data (1024 character)
The data in the Return Data field will be inserted into the email.
Example:
&CallPgm:MYPGM
The called program can return any value up to 1024 characters and that data will be inserted into the email.
Inserting File Name
You may insert the name of the file associated with the change using the following syntax:
&TableName
Inserting &TableName anywhere in the template will cause Database Monitor to insert the name of the file in that location.
Inserting User Name
You may insert the name of the user who made the change using the following syntax:
&User
Inserting &User anywhere in the template will cause Database Monitor to insert the name of the user in that location.
Inserting Date and Time
You may insert the date and time of the change using the following syntax:
&DateTime
Inserting &DateTime anywhere in the template will cause Database Monitor to insert the date and time of the change in that location.
Inserting Change Action
You may insert the change action (Add, Change, Update, Delete) using the following syntax:
&Action
Inserting &Action anywhere in the template will cause Database Monitor to insert the change action that location.
Examples
HTML Examples can be found in DATATHREAD/HTMSRC