Wiki source code of Notification
Show last authors
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 "from" informations. |
18 | |
19 | * email is a string representing his email address. |
20 | * title is a string representing his name. |
21 | |
22 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
23 | === (% style="font-size: 20.44px;" %)setReplyTo(email, title)(%%) === |
24 | |
25 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
26 | Set the "reply to" informations. |
27 | |
28 | * email is a string representing his email address. |
29 | * title is a string representing his name. |
30 | |
31 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
32 | === (% style="font-size: 20.44px;" %)setSender(email, title)(%%) === |
33 | |
34 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
35 | Set the "Sender" informations. |
36 | |
37 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
38 | * email is a string representing his email address. |
39 | * title is a string representing his name. |
40 | |
41 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
42 | === (% style="font-size: 20.44px;" %)setTo(recipient, group)(%%) === |
43 | |
44 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
45 | Set the recipient informations |
46 | |
47 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
48 | * recipient is either : |
49 | (% style="font-size: 14px;" %) |
50 | ** a string representing an email address |
51 | ** an Entity object representing a User or a Group |
52 | ** an Array of Entity objects of Users or Groups |
53 | * group is an Entity object representing a group used for delegation |
54 | |
55 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
56 | === (% style="font-size: 20.44px;" %)setCc(recipient)(%%) === |
57 | |
58 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
59 | Set the copy informations |
60 | |
61 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
62 | * recipient is either : |
63 | (% style="font-size: 14px;" %) |
64 | ** a string representing an email address |
65 | ** an Entity object representing a User or a Group |
66 | ** an Array of Entity objects of Users or Groups |
67 | |
68 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
69 | === (% style="font-size: 20.44px;" %)setBCc(recipient)(%%) === |
70 | |
71 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
72 | Set the copy informations |
73 | |
74 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
75 | * recipient is either : |
76 | (% style="font-size: 14px;" %) |
77 | ** a string representing an email address |
78 | ** an Entity object representing a User or a Group |
79 | ** an Array of Entity objects of Users or Groups |
80 | |
81 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start;" %) |
82 | ((( |
83 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
84 | === (% style="font-size: 20.44px;" %)setVariable(name, data)(%%) === |
85 | |
86 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
87 | 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} |
88 | |
89 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
90 | * name is the variable name, for example "data" |
91 | * data is an Entity object or a basic javascript object |
92 | |
93 | ((( |
94 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
95 | === (% style="font-size: 20.44px;" %)compose()(%%) === |
96 | |
97 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
98 | 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. |
99 | ))) |
100 | ))) |
101 | |
102 | |
103 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start;" %) |
104 | ((( |
105 | (% style="font-size: 14px;" %) |
106 | ((( |
107 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
108 | === (% style="font-size: 20.44px;" %)send()(%%) === |
109 | |
110 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start; line-height: 19.6px;" %) |
111 | Compose and send the notification. The notification is placed is the notification queue for asynchronous processing |
112 | ))) |
113 | ))) |
114 | |
115 | |
116 | (% style="text-align: start;" %) |
117 | ((( |
118 | ((( |
119 | (% style="font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: normal; text-align: start;" %) |
120 | === (% style="font-size: 20.44px;" %)send(notification)(%%) === |
121 | |
122 | (% style="text-align: start;" %) |
123 | (% style="line-height: 19.6px;" %)Send the notification. The notification is placed is the notification queue for asynchronous processing. |
124 | |
125 | * notification is an Entity object representing the notification. This object is the result of the compose function |
126 | ))) |
127 | ))) |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | (% style="font-family: sans-serif; font-style: normal; text-align: start;" %) |
134 | === (% 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);" %)Example:(%%) === |
135 | |
136 | {{code language="javascript"}} |
137 | var notif = new Notification(); |
138 | var template = sysNotificationTemplate.Get('402881e650a9d76c0150b7f4299d29ce'); |
139 | notif.init(template); |
140 | notif.setVariable("data", data); |
141 | |
142 | notif.setTo("user1@gmail.com"); |
143 | notif.setTo("user2@gmail.com"); |
144 | notif.setFrom("noreply@requea.com"); |
145 | notif.send(); |
146 | {{/code}} |