notification needs to be sent to users mentioned in variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 05:41 AM
HI Community,
I need to send notification to users mentioned in the variable.
In catalog item there is a variable set and the variable named notify (list collector) and refer to user table.... once the request is submitted with the user details in the notify field and when work notes/comments in catalog task are updated then notification needs to be sent to the users present in the notify variable.
How can we achieve this.
Thanks & Regards,
Suuriya Sridharan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 06:15 AM
Hi @suuriya ,
If you want to add list of users in TO address then use event triggered notification as you can't directly dot walk from notification.
If you want to add list of users in CC/BCC address then use event triggered notification as you can't directly dot walk from notification.
- Create a notification on Task table
Add the below code in email script
var notifyVariable = current.variables.notify;
if (notifyVariable) {
var userIDs = notifyVariable.split(',');
for (var i = 0; i < userIDs.length; i++) {
var userID = userIDs[i].trim();
var user = new GlideRecord('sys_user');
if (user.get(userID)) {
email.addAddress("cc",user.email);
}
Refer this link for more info
https://www.servicenow.com/community/developer-forum/how-to-add-quot-to-quot-address-in-email/m-p/1361830
I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 06:31 AM - edited 05-21-2024 06:33 AM
Hi @suuriya ,
This is possible to achieve. Please register a new event using the Event Registry module. Trigger this event when your trigger condition is met, i.e. on catalog task update/ on req_item update. Create a notification and configure it to run when event is fired. Pass the targeted audience details via event parms to Notification.
E.g. Trigger event using the following code:
gs.eventQueue('event_name', current, parm1, parm2);
use either parm1/parm2 to pass recipient details, set parm1 = notify_variable, and leave parm2 as empty string, i.e. ''.
On the Notification record, check 'Event parm 1 contains recipient'.
If my answer helped you in any way, please then mark it as helpful or correct.
Thanks,