Skip to main content
Version: 1.21.3

SimpleEmailTemplate

This class provides methods to execute the code on the server-side using Script Includes. Use it to create branded notifications.

setTitle(title)


Use this method to set the main header of the email notification.

Parameter(s):

NameTypeMandatoryDefault value
titleStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setTitle()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setTitle(`${current.number} ${current.subject}`);

setBodyHeader(bodyHeader)


Use this method to set the header of the notification text body.

Parameter(s):

NameTypeMandatoryDefault value
bodyHeaderStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setBodyHeader()
 let bodyHeaderTemplate = `<a href="${currentRecordURL}">${emailSubject}</a> <br> The state of ${current.number} changed, new state: ${current.getDisplayValue('state')}.`;
if(current.state == '3'){ //Postponed
bodyHeaderTemplate += `Repeated request: ${current.getDisplayValue('resubmission')}`;
}
bodyHeaderTemplate += `<br><br>You can add information by replying to this letter, do not change the subject of the letter. `;
htmlTemplate.setBodyHeader(bodyHeaderTemplate);

setBodyText(bodyText)


Use this method to set the main text body of the email notification.

Parameter(s):

NameTypeMandatoryDefault value
bodyTextStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setBodyText()
const htmlTemplate = new SimpleEmailTemplate(approvalItem.getDisplayValue());
const allApproversObject = JSON.parse(current.additional_parameter);
htmlTemplate.setBodyText(`Dear ${current.getDisplayValue('approver_id')}, you need to approve <a href="${ApprovalItemURL}">${approvalItem.getDisplayValue()}</a> The list of the approval tickets: ${transformToTemplateList(allApproversObject)}`);

setComment(comment)


Use this method to set the email notification comment in the following way:

  • put it in an area with a gray background.
  • highlight it italic.

Parameter(s):

NameTypeMandatoryDefault value
commentStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setComment()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setComment(`Comment: ${current.additional_comments}`);

getTitle()


Use this method to return the main header of the notification.

Return:

TypeDescription
StringThis method returns the main header of the notification.

Example:

getTitle()
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setTitle(`${current.number} ${current.subject}`);
ss.info(htmlTemplate.getTitle()); // Result: INC0000XXX Email not working

getBodyHeader()


Use this method to return the main header of the text body.

Return:

TypeDescription
StringThis method returns the main header of the text body.

Example:

getBodyHeader()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setBodyHeader(`Incident ${current.number} ${current.subject}`);
ss.info(htmlTemplate.getBodyHeader()); // Result: Incident INC0000XX Email not working

getBodyText()


Use this method to return the text body.

Return:

TypeDescription
StringThis method returns the main text body.

Example:

getBodyText()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setBodyText(`Description ${current.description}`);
ss.info(htmlTemplate.getBodyText()); // Result: Description 27.01.2022 Could not log in to my email, the error 'No access'.

getComment()


Use this method to return a comment text.

Return:

TypeDescription
StringThis method returns а comment text.

Example:

getComment()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setComment(`Comment: ${current.additional_comments}`);
ss.info(htmlTemplate.getComment()); // Result: Need more information

getButtons()


Use this method to return the array of buttons.

Return:

TypeDescription
ArrayThis method returns an array of buttons.

Example:

getButtons()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.addButton('Approve', 'https://instance.example.com');
ss.info(htmlTemplate.getButtons()); // Results: [{"text":"Approve","url":"https:\/\/instance.example.com\/","color":"#05C270"},{"text":"Reject","url":"https:\/\/instance.example.com\/","color":"#F73422"}]

addButton()


Use this method to add a new button to the array of buttons.

Parameter(s):

NameTypeMandatoryDefault value
textStringYN
urlStringYN
colorStringNN
buttonArrayArrayYN

Return:

TypeDescription
ArrayThis method returns an array of buttons, including the new one.

Example:

addButtons()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.addButton('Approve', 'https://instance.example.com');

removeButton()


Use this method to remove the last added button.

Return:

TypeDescription
VoidThis method does not return a value.

Example:

removeButton()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.addButton('Approve', 'https://instance.example.com');
if (current.state === '2') { // Incident in the 'In Progress' state
htmlTemplate.removeButton();
}

removeAllButtons()


Use this method to remove all added buttons.

Return:

TypeDescription
VoidThis method does not return a value.

Example:

removeAllButtons()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.addButton('Approve', 'https://instance.example.com');
htmlTemplate.addButton('Reject', 'https://instance.example.com');
if (current.state === '3') { Incident in the 'Postponed' state
htmlTemplate.removeAllButtons();
}

setProperty(propertyName, input, propertyTitle)


Use this method to set an internal method for input type validation.

Parameter(s):

NameTypeMandatoryDefault value
propertyNameStringYN
inputString/NumberYN
propertyTitleStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

setProperty()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setProperty('bodyText', Need information about the incident', 'Body Text');
ss.info(htmlTemplate.getBodyText()); // Result: Need information about the incident

formEmailTemplate()


Use this method to create and return an HTML template based on the set properties.

Return:

TypeDescription
StringThis method returns an HTML template.

Example:

formEmailTemplate()
ss.importIncludeScript('SimpleEmailTemplate');
const htmlTemplate = new SimpleEmailTemplate('');
htmlTemplate.setTitle(`${current.number} ${current.subject}`);
htmlTemplate.setComment(`Comment: ${current.additional_comments}`);
htmlTemplate.setBodyHeader(`Incident ${current.number} ${current.subject}`);
htmlTemplate.setBodyText(`Description: ${current.description}`);
email.setBody(htmlTemplate.formEmailTemplate());