Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This class allows the client-side script to execute the code on the server-side using Script Includes. it is used to create branded notifications.

 setTitle(title)


This method sets the main header of email notification.

Parameter(s):

Name

Type

Mandatory

Default value

titleStringYN

Return:

Type

Description

VoidThis method does not return a value.


Code Block
languagejs
themeEclipse
titlesetTitle
linenumberstrue
   

setBodyHeader(bodyHeader)


This method sets the header of text body of email notification.

Parameter(s):

Name

Type

Mandatory

Default value

bodyHeaderStringYN

Return:

Type

Description

VoidThis method does not return a value.


Code Block
languagejs
themeEclipse
titlesetBodyHeader
linenumberstrue
  let bodyHeaderTemplate = `<a href="${currentRecordURL}">${emailSubject}</a>
  <br><br>
  The state changed ${current.number}, 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)
setBodyHeader

setBodyText(

bodyHeader

bodyText)


This method sets the header of main text body of email notification.

Parameter(s):

Name

Type

Mandatory

Default value

bodyHeaderbodyTextStringYN

Return:

Type

Description

VoidThis method does not return a value.


Code Block
languagejs
themeEclipse
titlesetBodyHeadersetBodyText
linenumberstrue
setBodyHeader(bodyHeader) {
   const htmlTemplate = new  this.setProperty('bodyHeader', bodyHeader, 'You have a new approval ticket'SimpleEmailTemplate(approvalItem.getDisplayValue());
    const allApproversObject = JSON.parse(current.additional_parameter);
    }

setBodyText(bodyText)

This method sets the main text body of email notification.

Parameter(s):

Name

Type

Mandatory

Default value

bodyTextStringYN

Return:

Type

Description

VoidThis method does not return a value.
Code Block
languagejs
themeEclipse
titlesetBodyText
linenumberstrue
setBodyText(bodyText) {
        this.setProperty('bodyText', bodyText, 'You need to approve or reject the ticket.');
    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)


This method sets the email notification comment:

  • puts it in an area with a grey background 
  • highlights it italic.

Parameter(s):

Name

Type

Mandatory

Default value

commentStringYN

Return:

Type

Description

VoidThis method does not return a value.


Code Block
languagejs
themeEclipse
titlesetComment
linenumberstrue
 setComment(comment) {
        this.setProperty('comment', comment, 'Leave your comment here');
    }

getTitle(title)


This method returns the main header of notification.

Return:

Type

Description

StringThe main header of notification.


Code Block
languagejs
themeEclipse
titlegetTitle
linenumberstrue
getTitle() {
        return this.title;
    }

getBodyHeader(bodyHeader)


This method returns the main header of text body.

Return:

Type

Description

StringThe main header of text body.


Code Block
languagejs
themeEclipse
titlegetBodyHeader
linenumberstrue
getBodyHeader() {
        return this.bodyHeader;
    }

getBodyText(bodyText)


This method returns the main text body.

Return:

Type

Description

StringThe main text body.


Code Block
languagejs
themeEclipse
titlegetBodyText
linenumberstrue
getBodyText() {
        return this.bodyText;
    }

getComment(comment)


This method returns the comment text.

Return:

Type

Description

StringThe comment text.


Code Block
languagejs
themeEclipse
titlegetComment
linenumberstrue
getComment() {
        return this.comment;
    }

getButtons(buttons)


This method returns the array of buttons.

Return:

Type

Description

ArrayThe array of buttons.


Code Block
languagejs
themeEclipse
titlegetButtons
linenumberstrue
getButtons() {
        return this.buttons;
    }

addButton(button)


This methods adds a new button to array of buttons.
Parameter(s):

Name

Type

Mandatory

Default value

textStringYN
urlStringYN
colorStringYN
buttonArrayArrayYN

Return:

Type

Description

ArrayThe base of buttons array with the new one.


Code Block
languagejs
themeEclipse
titleaddButtons
linenumberstrue
 addButton(text, url, color   const htmlTemplate = '#E31450') {
  new SimpleEmailTemplate(approvalItem.getDisplayValue());
       const buttonallApproversObject = {JSON.parse(current.additional_parameter);
    htmlTemplate.setBodyText(`Dear ${current.getDisplayValue('approver_id')}, you need to approve <a   "text": text,href="${ApprovalItemURL}">${approvalItem.getDisplayValue()}</a>
    The list of the     "url": url,approval tickets:
    ${transformToTemplateList(allApproversObject)}
    htmlTemplate.addButton('Reject',    "color": colorrejectURL, '#f74d4d');
    // email   };update

removeButton(button)


 This method removes the last added button.

Code Block
languagejs
themeEclipse
titleremoveButton
linenumberstrue
 removeButton() {
        this.buttons.pop();
    }

removeAllButtons(buttons)


This method removes all added buttons.

Code Block
languagejs
themeEclipse
titleremoveAllButtons
linenumberstrue
removeAllButtons() {
        this.buttons = [];
    }

setProperty(propertyName, input, propertyTitle)


This method sets internal method for input type validation.

Parameter(s):

Name

Type

Mandatory

Default value

propertyNameStringYN
inputString/NumberYN
propertyTitleStringYN


Code Block
languagejs
themeEclipse
titlesetProperty
linenumberstrue
 setProperty(propertyName, input, propertyTitle) {
        if (typeof input === 'string' || typeof input === 'number') {
            this[propertyName] = input;
        } else {
            ss.addErrorMessage(`Invalid data type.`);
        }
    }

formEmailTemplate()


This method creates and returns HTML template based on set properties.

Return:

Type

Description

StringThe HTML template.


Code Block
languagejs
themeEclipse
titleformEmailTemplate
linenumberstrue
formEmailTemplate() {
        //text formatter - \n to <br>
        const bodyText = this.bodyText.toString().replace(/\n/g, '<br>');

        //creates space between bodyHeader and bodyText
        let bodySplitter = '';
        if (this.bodyHeader !== '' && this.bodyHeader !== '') {
            bodySplitter = '<br><br>';
        }