You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

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.
    setTitle(title) {
        this.setProperty('title', title, 'Approval ticket');
    }

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.
setBodyHeader(bodyHeader) {
        this.setProperty('bodyHeader', bodyHeader, 'You have a new approval ticket');
    }

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.
setBodyText(bodyText) {
        this.setProperty('bodyText', bodyText, 'You need to approve or reject the ticket.');
    }

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.
 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.
getTitle() {
        return this.title;
    }

getBodyHeader(bodyHeader)


This method returns the main header of text body.

Return:

Type

Description

StringThe main header of text body.
getBodyHeader() {
        return this.bodyHeader;
    }

getBodyText(bodyText)


This method returns the main text body.

Return:

Type

Description

StringThe main text body.
getBodyText() {
        return this.bodyText;
    }

getComment(comment)


This method returns the comment text.

Return:

Type

Description

StringThe comment text.
getComment() {
        return this.comment;
    }

getButtons(buttons)


This method returns the array of buttons.

Return:

Type

Description

ArrayThe array of buttons.
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.
 addButton(text, url, color = '#E31450') {
        const button = {
            "text": text,
            "url": url,
            "color": color
        };

removeButton(button)


 This method removes the last added button.

 removeButton() {
        this.buttons.pop();
    }

removeAllButtons(buttons)


This method removes all added buttons.

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
 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.
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>';
        }


  • No labels