Class Index | File Index

Classes


Namespace LABKEY.Message

LabKey Email Notification Helper class. This class provides static methods to generate an email notification message that gets sent from the LabKey SMTP server.

Additional documentation on SMTP setup for LabKey Server:


Defined in: Message.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
<static>  
LABKEY.Message.msgType
A map of the email message body types.
<static>  
LABKEY.Message.recipientType
A map of the email recipient types.
Method Summary
Method Attributes Method Name and Description
<static>  
LABKEY.Message.createMsgContent(type, content)
A utility function to create a message content object used in LABKEY.Message.sendMessage.
<static>  
LABKEY.Message.createPrincipalIdRecipient(type, id)
A utility function to create a recipient object (based on a user ID or group ID) used in LABKEY.Message.sendMessage.
<static>  
LABKEY.Message.createRecipient(type, email)
A utility function to create a recipient object used in LABKEY.Message.sendMessage.
<static>  
LABKEY.Message.sendMessage(config)
Sends an email notification message through the LabKey Server.
Namespace Detail
LABKEY.Message
Field Detail
<static> LABKEY.Message.msgType
A map of the email message body types. Email messages can contain multiple content types allowing a client application the option to display the content it is best suited to handle. A common practice is to include both plain and html body types to allow applications which cannot render html content to display a plain text version. The values in this map are as follows: For example, to refer to the html type, the syntax would be:
LABKEY.Message.msgType.html

<static> LABKEY.Message.recipientType
A map of the email recipient types. The values in this map are as follows: For example, to refer to the cc type, the syntax would be:
LABKEY.Message.recipientType.cc
Method Detail
<static> LABKEY.Message.createMsgContent(type, content)
A utility function to create a message content object used in LABKEY.Message.sendMessage.
Parameters:
{LABKEY.Message.msgType} type
The content type of this message part.
{String} content
The message part content.

<static> LABKEY.Message.createPrincipalIdRecipient(type, id)
A utility function to create a recipient object (based on a user ID or group ID) used in LABKEY.Message.sendMessage. Note: only server side validation or transformation scripts can specify a user or group ID.
Parameters:
{LABKEY.Message.recipientType} type
Determines where the recipient email address will appear in the message.
{Integer} id
The user or group id of the recipient.

<static> LABKEY.Message.createRecipient(type, email)
A utility function to create a recipient object used in LABKEY.Message.sendMessage.
Parameters:
{LABKEY.Message.recipientType} type
Determines where the recipient email address will appear in the message.
{String} email
The email address of the recipient.

<static> {Mixed} LABKEY.Message.sendMessage(config)
Sends an email notification message through the LabKey Server. Message recipients and the sender must exist as valid accounts, or the current user account must have permission to send to addresses not associated with a LabKey Server account at the site-level, or an error will be thrown.
Example:
         
         <script type="text/javascript">
         
         function errorHandler(errorInfo, responseObj)
         {
             LABKEY.Utils.displayAjaxErrorResponse(responseObj, errorInfo);
         }

         function onSuccess(result)
         {
             alert('Message sent successfully.');
         }

         LABKEY.Message.sendMessage({
             msgFrom: 'admin@test.com',
             msgSubject: 'Testing email API...',
             msgRecipients: [
                 LABKEY.Message.createRecipient(LABKEY.Message.recipientType.to, 'user1@test.com'),
                 LABKEY.Message.createRecipient(LABKEY.Message.recipientType.cc, 'user2@test.com'),
                 LABKEY.Message.createRecipient(LABKEY.Message.recipientType.cc, 'user3@test.com'),
                 LABKEY.Message.createRecipient(LABKEY.Message.recipientType.bcc, 'user4@test.com')
             ],
             msgContent: [
                 LABKEY.Message.createMsgContent(LABKEY.Message.msgType.html, '<h2>This is a test message</h2>'),
                 LABKEY.Message.createMsgContent(LABKEY.Message.msgType.plain, 'This is a test message')
             ],
             success: onSuccess,
             failure: errorHandler,
         });
         </script>
         
Parameters:
config
A configuration object containing the following properties
{String} config.msgFrom
The email address that appears on the email from line.
{String} config.msgSubject Optional
The value that appears on the email subject line.
{Object[]} config.msgRecipients
An array of recipient objects which have the following properties:
  • type: the recipient type, must be one of the values from: LABKEY.Message.recipientType.
  • address: the email address of the recipient.
The utility function LABKEY.Message.createRecipient can be used to help create these objects.
{Object[]} config.msgContent
An array of content objects which have the following properties:
  • type: the message content type, must be one of the values from: LABKEY.Message.msgType.
  • content: the email message body for this content type.
The utility function LABKEY.Message.createMsgContent can be used to help create these objects.
{function} config.success Optional
A reference to a function to call if the action succeeds. This function will be passed the following parameters:
  • result: an object containing a boolean property: success..
  • response: The XMLHttpResponse object
{function} config.failure Optional
A reference to a function to call when an error occurs. This function will be passed the following parameters:
  • errorInfo: an object containing detailed error information (may be null)
  • response: The XMLHttpResponse object
{object} config.scope Optional
A scoping object for the success and error callback functions (default to this).
Returns:
{Mixed} In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks.)

Documentation generated by JsDoc Toolkit 2.3.2 on Tue Sep 11 2018 10:10:59 GMT-0000 (UTC)