You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 15 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 |
---|---|---|---|
title | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
setBodyHeader(bodyHeader)
This method sets the header of text body of email notification.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
bodyHeader | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
let bodyHeaderTemplate = `<a href="${currentRecordURL}">${emailSubject}</a> <br><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)
This method sets the main text body of email notification.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
bodyText | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
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)
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 |
---|---|---|---|
comment | String | Y | N |
Return:
Type | Description |
---|---|
Void | This 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 |
---|---|
String | The main header of notification. |
getTitle() { return this.title; }
getBodyHeader(bodyHeader)
This method returns the main header of text body.
Return:
Type | Description |
---|---|
String | The main header of text body. |
getBodyHeader() { return this.bodyHeader; }
getBodyText(bodyText)
This method returns the main text body.
Return:
Type | Description |
---|---|
String | The main text body. |
getBodyText() { return this.bodyText; }
getComment(comment)
This method returns the comment text.
Return:
Type | Description |
---|---|
String | The comment text. |
) { ss.importIncludeScript('NotificationsInApprovalContextUtility'); const notificationUtility = new NotificationsInApprovalContextUtility(current); return notificationUtility.getComments(); })(current, template, email, event);
getButtons(buttons)
This method returns the array of buttons.
Return:
Type | Description |
---|---|
Array | The 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 |
---|---|---|---|
text | String | Y | N |
url | String | Y | N |
color | String | Y | N |
buttonArray | Array | Y | N |
Return:
Type | Description |
---|---|
Array | The base of buttons array with the new one. |
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)} htmlTemplate.addButton('Reject', rejectURL, '#f74d4d'); // email update
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 |
---|---|---|---|
propertyName | String | Y | N |
input | String/Number | Y | N |
propertyTitle | String | Y | N |
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 |
---|---|
String | The 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