1.4

5. Write a script that appends a <link> element to the results (the selector is head, so the
results contain the <head> of the email).
l
Make sure to set the rel attribute to related.
l
The href attribute determines where the file comes from. For resources inside of the
template, use 'images/file.extension' , or 'fonts/myfont.otf', etc.
For external resources, you need the full path to the file, such as
'file:///c:/resources/attachments/instructions.pdf'. Of course,
you can also use dynamic calls such as 'file:///c:/clientfiles/' +
record.fields.client_id + '/invoices/' +
record.fields.invoice_number + '.pdf'.
Examples
The following script attaches a PDF file named letter-CU00048376.pdf to each generated
email. The PDF file is located in the Images folder on the Resources panel.
results.append("<link rel='related' href='images/letter-
CU00048376.pdf'>");
If that same file would be located on the C: drive, the script should refer to it as follows:
href='file:///C:/letter-CU00048376.pdf'.
The link doesn't have to be static; you could use data from the record set to build the link, for
example:
var customerID = record.fields.ID;
results.append('<link rel="related" href="images/letter-' +
customerID + '.pdf">');
Generating output
When merged with a record set, the templates made in the Designer can generate twotypes of
output: Print, and Email.
Print output
Print templates, also called Print sections, are part of the Print context. They are meant to be printed to a
printer or printer stream, or to a PDF file (see "Generating Print output" on the facing page).
The Print context can also be added to Email output as a PDF attachment; see "Generating Email output"
on page 148. When generating output from the Print context, each of the Print sections is added to the
output document, one after the other in sequence, for each record.
To dynamically select a section for output, use a Control Script; see "Control Scripts" on page
208.
Page 137