Versions Compared

Key

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

This server-side class is intended to implement the email objects for applications; in addition to these methods, use the email global object available in notification scripts.

addAddress(address, displayName)


This method adds the address to the email listpopulates the To field of the Email (sys_email) table record with address specified.


Parameter(s):

NameTypeMandatoryDefault Value
addressStringYN
displayNameString
|
or NullN'NULL'


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddAddress
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.addAddress(“test@examplecurrent.caller.com”email, “example”current.caller.display_name);
})(current, template, email, event);


addAddressBcc(address, displayName)


This method adds the address to the BCC's emails listpopulates the Blind Carbon Copy (BCC) field of the Email (sys_email) table record with address specified.


Parameter(s):

NameTypeMandatoryDefault Value
addressStringYN
displayNameString
|
or NullN'NULL'


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddAddressBcc
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  if (+event.param_2 > 1000) {
    email. addAddressBcc(“test@example.com”, “copy2 example”);
      current.assigned_user.manager.email,
      current.assigned_user.manager.display_name
    );
  }
})(current, template, email, event);


addAddressCc(address, displayName)


This method adds the address to the CC's emails listpopulates the Carbon Copy (CC) field of the Email (sys_email) table record with address specified.


Parameter(s):

NameTypeMandatoryDefault Value
addressStringYN
displayNameString
|
or NullN'NULL'


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddAddressCc
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email. addAddressCc(“test@example.com”'john.doe@example.com', “copy'John example”Doe');
})(current, template, email, event);

getAddresses()


This method gets the recipients' addresses.


Return:

TypeDescription
StringThe A string containing the recipient's addresses.


Example:

Code Block
languagejs
themeEclipse
titlegetAddresses
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getAddresses();
})(current, template, email, event);

getAddressesBcc()


This method gets the recipients' BCC addresses.


Return:

TypeDescription
StringThe A string containing the recipient's BCC addresses.


Example:

Code Block
languagejs
themeEclipse
titlegetAddressesBcc
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getAddressesBcc();
})(current, template, email, event);


getAddressesCc()


This method gets the recipients' CC addresses.


Return:

TypeDescription
StringThe A string containing the recipient's CC addresses.


Example:

Code Block
languagejs
themeEclipse
titlegetAddressesCc
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getAddressesCc();
})(current, template, email, event);

Method description

Parameter


getBody(

s

)

:NameTypeMandatoryDefault Value


This method gets the message body.


Return:

TypeDescription
StringThe message body.


Example:

Code Block

Method description

Parameter(s):

NameTypeMandatory
languagejs
themeEclipse
titlegetBody
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getBody();
})(current, template, email, event);


getFrom()


This method gets the sender's address.

Default Value


Return:

TypeDescription
StringA string containing the sender's address.


Example:

Code Block

Method description

Parameter(s):

NameTypeMandatory
languagejs
themeEclipse
titlegetForm
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getFrom();
})(current, template, email, event);


getReplyTo()


This method gets the replyTo address.

Default Value


Return:

TypeDescription
StringA string containing the replyTo address.


Example:

Code Block

Method description

Parameter(s):

NameTypeMandatoryDefault Value
languagejs
themeEclipse
titlegetReplyTo
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getReplyTo();
})(current, template, email, event);


getSubject()


This method returns the subject of a message.


Return:

TypeDescription
StringA string containing the message subject line.


Example:

Code Block
languagejs
themeEclipse
titlegetSubject
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.getSubject();
})(current, template, email, event);


setBody(bodyText)


This method sets the body of a message.Method description


Parameter(s):

NameTypeMandatoryDefault Value
bodyTextStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block

Method description

Parameter(s):

NameTypeMandatoryDefault Value
languagejs
themeEclipse
titlesetBody
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.setBody(`Additional comments:
${current.sys_updated_by.display_name}: "${current.additional_comments}"`
  );
})(current, template, email, event);


setFrom(address)


By default, the outgoing email From field contains the address taken from the From field of the default email account. Use the setFrom(address) method to change the From field value of an outgoing email.

It is impossible to change the email account for the outgoing email with this method. To change the default email account, change the value of the system property default.email.account.send.

The value of the argument must be valid for the regular expression set in the email.validation.reg_exp property.

Regardless of the value in the Form field of an outgoing email, the system conducts the sending authorization with the data set in the default email account.

Return:

TypeDescription

Example:

Code Block

Method description


Parameter(s):

NameTypeMandatoryDefault Value
addressStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetFrom
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.setFrom('test@example.com');
})(current, template, email, event);


setReplyTo(address)


This method sets the replyTo address. The argument value of the method must be valid for the regular expression set in the email.validation.reg_exp property.Method description


Parameter(s):

NameTypeMandatoryDefault Value
addressStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetReplyTo
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.setReplyTo('test@example.com');
})(current, template, email, event);


setSubject(subject)


This method sets the subject of an email.Method description


Parameter(s):

NameTypeMandatoryDefault Value
subjectStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetSubject
(function runNotificationScript(
    /* SimpleRecord */ current, 
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {
  email.setSubject('Additional comments have been added');
  email.setBody(`Additional comments:
${current.sys_updated_by.display_name}: "${current.additional_comments}"`
  );
})(current, template, email, event);


Table of Contents
absoluteUrltrue
classfixedPosition