Notification
Api to send emails or SMS using a notification template. Notification templates can be defined in Administration tab, "Workflows and Notifications" menu and "Notifications Templates" menu
Functions
init(template)
Init the notification with the template. template in an Entity object.
setFrom(email, title)
Set the "from" informations.
- email is a string representing his email address.
- title is a string representing his name.
setReplyTo(email, title)
Set the "reply to" informations.
- email is a string representing his email address.
- title is a string representing his name.
setSender(email, title)
Set the "Sender" informations.
- email is a string representing his email address.
- title is a string representing his name.
setTo(recipient, group)
Set the recipient informations
- recipient is either :
- a string representing an email address
- an Entity object representing a User or a Group
- an Array of Entity objects of Users or Groups
- group is an Entity object representing a group used for delegation
setCc(recipient)
Set the copy informations
- recipient is either :
- a string representing an email address
- an Entity object representing a User or a Group
- an Array of Entity objects of Users or Groups
setBCc(recipient)
Set the copy informations
- recipient is either :
- a string representing an email address
- an Entity object representing a User or a Group
- an Array of Entity objects of Users or Groups
setVariable(name, data)
Set a variable in the javascript context used to compose the notification. Subject and Body of the notification template can be composed dynamically with variable resolution using the following syntax : ${data.rqTitle}
- name is the variable name, for example "data"
- data is an Entity object or a basic javascript object
compose()
Build the notification using the templates, parameters and variables set and returns en Entity object representing the notification. The notification can be modified before being sent.
send()
Compose and send the notification. The notification is placed is the notification queue for asynchronous processing
send(notification)
Send the notification. The notification is placed is the notification queue for asynchronous processing.
- notification is an Entity object representing the notification. This object is the result of the compose function
Example:
var template = sysNotificationTemplate.Get('402881e650a9d76c0150b7f4299d29ce');
notif.init(template);
notif.setVariable("data", data);
notif.setTo("user1@gmail.com");
notif.setTo("user2@gmail.com");
notif.setFrom("noreply@requea.com");
notif.send();