Print

GetAttachmentFromTemplate()

The GetAttachmentFromTemplate() function creates a file based on a given template and returns its content as a file object. This function does not attach the created file to the case. This created file object may be, for example, downloaded with DownloadFile() or sent with SendMessageEx() functions. CAUTION! If the template contains merge fields they will be filled with values from related fields on the case form.

Syntax

GetAttachmentFromTemplate(templateName,[fileName]);

Function arguments

  • templateName – (String) a name of the template file;
  • fileName – (String) [optional] a name of the resulting file. If ommited then the file name will be set to the template name with caseid before extension.

Return value

The GetAttachmentFromTemplate() function returns a file object.
Returns created file.

Examples

Example 1

This will create a document based on the „Contract.docx” template and assign it to a variable (a file object). Then the fileName property is set. At the end the file variable is passed to the DownloadFile() function.

file=GetAttachmentFromTemplate("Contract.docx");
file.fileName="Contract_"+[Number]+".docx";
DownloadFile(file);

Example 2

This will create a document based on the „Contract.docx” template with its name passed as a second parameter. Then the file variable is passed to the DownloadFile() function.

file=GetAttachmentFromTemplate("Contract.docx","Contract_"+[Number]+".docx");
DownloadFile(file);

Example 3

This will create a document based on the „Contract.docx” template with its name passed as a second parameter. Then it is added to an email object and sent as an attachment.

file=GetAttachmentFromTemplate("Contract.docx","Contract_"+[Number]+".docx");
mail.recipient=[User];
mail.subject=[Subject];
mail.message=[Message];
AddFileToList(mail.attachments,file);
SendMessageEx(mail);
Czy artykuł był pomocny?
0 na 5 gwiazdek
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?