- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 12:05 PM
Hello All,
We have an Event which triggers a notification on Security Incident response.
I am looking for code of adding Users email address to event so that the notification can be sent to email address of users in Affected user related list.
Table : sn_si_m2m_task_affected_user
Event : gs.eventQueue('sn_si.secops.trigger.spam.email', current, '', '');
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:43 AM
Okay then writedown code as below. But make sure you have push the correct email address by writing proper field name for email in below script.
var userList = [];
var userRec = new GlideRecord("sn_si_m2m_task_affected_user");
userRec.addQuery('task',current.sys_id);
userRec.query();
while (userRec.next()) {
if (userList.toString().indexOf(userRec.sys_id) == -1) {
userList.push(userRec.sys_id + "");
}
}
gs.eventQueue('sn_si.trigger.spam.email', current, userList.toString(),"");
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:31 AM
But where did you written that above script?
In email Script or in BR or somewhere else ?
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:39 AM
Ui action, event is associated with a UI action on Security Incident table.
trigger UI action >>Event >>notification to users in related list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:43 AM
Okay then writedown code as below. But make sure you have push the correct email address by writing proper field name for email in below script.
var userList = [];
var userRec = new GlideRecord("sn_si_m2m_task_affected_user");
userRec.addQuery('task',current.sys_id);
userRec.query();
while (userRec.next()) {
if (userList.toString().indexOf(userRec.sys_id) == -1) {
userList.push(userRec.sys_id + "");
}
}
gs.eventQueue('sn_si.trigger.spam.email', current, userList.toString(),"");
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 11:56 AM
thanks Gunjan the code worked .. You have been really helpful. cheers !
this is the code that worked :
var userList = [];
var userRec = new GlideRecord("sn_si_m2m_task_affected_user");
userRec.addQuery('task',current.sys_id);
userRec.query();
while (userRec.next()) {
if (userList.toString().indexOf(userRec.sys_id) == -1) {
userList.push(userRec.user.email + "");
}
}