Hide last authors
Maurice Gasco 3.2 1 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
2 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
3
4 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
5 == (% style="font-size: 22.54px; background-color: rgb(245, 245, 245);" %)Functions(%%) ==
6
7 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
8 === (% style="font-size: 20.44px;" %)init(template)(%%) ===
9
10 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
11 Init the notification with the template. template in an Entity object.
12
13 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
14 === (% style="font-size: 20.44px;" %)setFrom(email, title)(%%) ===
15
16 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
17 Set the sender informations.
18
19
20 * (% style="font-size: 14px; text-align: start; background-color: rgb(245, 245, 245);" %)email is a string representing the email address of the sender.
21 * (% style="font-size: 14px; text-align: start; background-color: rgb(245, 245, 245);" %)title is a string representing his name.
22
23 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
24 === (% style="font-size: 20.44px;" %)setReplyTo(email, title)(%%) ===
25
26 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
27 Set the "reply to" informations.
28
29
30 * (% style="font-size: 14px; text-align: start; background-color: rgb(245, 245, 245);" %)email is a string representing the email address of the sender.
31 * (% style="font-size: 14px; text-align: start; background-color: rgb(245, 245, 245);" %)title is a string representing his name.
32
33 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
34 === (% style="font-size: 20.44px;" %)setTo(recipient, group)(%%) ===
35
36 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
37 Set the recipient informations
38
39 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
40 * recipient is either :
Maurice Gasco 4.1 41 (% style="font-size: 14px;" %)
Maurice Gasco 3.2 42 ** a string representing an email address
43 ** an Entity object representing a User or a Group
44 ** an Array of Entity objects of Users or Groups
45 * group is an Entity object representing a group used for delegation
46
47
Maurice Gasco 4.1 48 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
49 === (% style="font-size: 20.44px;" %)setCc(recipient)(%%) ===
50
Maurice Gasco 3.2 51 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
Maurice Gasco 4.1 52 Set the copy informations
Maurice Gasco 3.2 53
Maurice Gasco 4.1 54 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
55 * recipient is either :
56 (% style="font-size: 14px;" %)
57 ** a string representing an email address
58 ** an Entity object representing a User or a Group
59 ** an Array of Entity objects of Users or Groups
60
61
62 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
63 === (% style="font-size: 20.44px;" %)setBCc(recipient)(%%) ===
64
65 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
66 Set the copy informations
67
68 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
69 * recipient is either :
70 (% style="font-size: 14px;" %)
71 ** a string representing an email address
72 ** an Entity object representing a User or a Group
73 ** an Array of Entity objects of Users or Groups
74
75 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start;" %)
76 (((
77 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
78 === (% style="font-size: 20.44px;" %)setVariable(name, data)(%%) ===
79
80 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
81 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}
82
83 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
84 * name is the variable name, for example "data"
85 * data is an Entity object or a basic javascript object
86
87 (((
88 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
89 === (% style="font-size: 20.44px;" %)compose()(%%) ===
90
91 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
92 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.
93 )))
94 )))
95
96
97 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start;" %)
98 (((
99 (% style="font-size: 14px;" %)
100 (((
101 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
102 === (% style="font-size: 20.44px;" %)send()(%%) ===
103
104 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %)
105 Compose and send the notification
106 )))
107 )))
108
109
110 (% style="text-align: start;" %)
111 (((
112 (((
113 (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start;" %)
114 === (% style="font-size: 20.44px;" %)send(notification)(%%) ===
115
116 (% style="text-align: start;" %)
117 (% style="line-height: 19.6px;" %)Send the notification.
118
119 * notification is an Entity object representing the notification. This object is the result of the compose function
120 )))
121 )))
122
123
124
125
126
127 (% style="font-family: sans-serif; font-style: normal; text-align: start;" %)
128 === (% style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 19.6px; text-align: start; background-color: rgb(245, 245, 245);" %)Examples:(%%) ===
129
130 {{code language="javascript"}}
131 var notif = new Notification();
132 notif.init(param);
133 notif.setVariable("data", data);
134
135 notif.setTo("user1@gmail.com");
136 notif.setTo("user2@gmail.com");
137 notif.setFrom("noreply@requea.com");
138 notif.send();
139 {{/code}}
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 9.11.5 - Documentation