Notification

Version 5.1 by Maurice Gasco on 2015/10/30 09:50

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 sender informations.

  • email is a string representing the email address of the sender.
  • title is a string representing his name.

setReplyTo(email, title)

Set the "reply to" informations.

  • email is a string representing the email address of the sender.
  • 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

send(notification)

Send the notification.

  • notification is an Entity object representing the notification. This object is the result of the compose function

Examples:

var notif = new Notification();
notif.init(param);
notif.setVariable("data", data);

notif.setTo("user1@gmail.com");
notif.setTo("user2@gmail.com");
notif.setFrom("noreply@requea.com");
notif.send();
Tags:
Created by Pierre Dubois on 2012/05/31 15:17
     
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 9.11.5 - Documentation