
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 04:44 PM
So what I want to do is I thought somewhat simple and it might be, but not for me currently lol
I have a list of services, each service has a bunch of users associated with each one. What I want to be able to do is to send an email notification to the list of users for whichever service has been selected.
I have a catalog item with a reference field called u_service which is using the cmdb_ci_service table. I want the notification to send at a point in the flow to all users associated with the selected service.
This is what I mean by users associated:
Anyone able to help me please, with actual instructions for my exact situation - I've looked at different forum chats already and found a heap, none of them are exactly what I want to do and I can't adapt them to do what I need either.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 12:24 AM
Hi @Bidduam
My above approach is for scripting part. You can refer to below for flow designer in your scenario.
1. Firstly, there should be a step to get catalog variable.
2. Then come to the Fire Event step.
Script
var service = fd_data._1__get_catalog_variables.u_service_affected; //call your variable from the 1st step
var users = [];
var gr = new GlideRecord('m2m_sp_status_subscription'); //your relationship table
gr.addQuery('cmdb_ci_service', service);
gr.query();
while(gr.next()){
users.push(gr.getValue('sys_user'));
}
return users;
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 09:12 PM
Hi @Bidduam
Let give the following steps a try to send a notification to multiple users associated with a service.
1. Define an Event Registry
2. Define a Notification triggered when the event is fired and the Event parm 1 contains recipient enabled.
3. Query the relationship table to collect all associated users.
4. Fire the event where you want to send the notification.
Sample script below.
var users = [];
var gr = new GlideRecord('m2m_sp_status_subscription'); //your relationship table
gr.addQuery('cmdb_ci_service', <your_service_variable>); //your variable
gr.query();
while(gr.next()){
users.push(gr.getValue('sys_user'));
}
if(users.length > 0){
gs.eventQueue('sc.catalog.notf.service_users', current, users); //replace your event name and the current RITM record.
}
Event queue:
Mail log:
Cheers,
Tai Vu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 09:07 PM
@Tai Vu thank you for your reply, I get most of what you are suggesting I do to make this work and what I have tried to do with your recommendation is:
- Added a new event to the event registry called - art.notify.send
- The service variable name I'm using is - u_service_affected
- I've created a flow that at a certain point creates a new event record:
- I've created a notification that is triggered by the event - art.notify.send
- I added the script you offered to the advanced section of the notification (thinking this is not the right place, but not sure what the right place would be - catalog client script of the catalog item?)
Script:
var users = [];
var gr = new GlideRecord('m2m_sp_status_subscription'); //your relationship table
gr.addQuery('cmdb_ci_service', 'variables.u_service_affected'); //your variable
gr.query();
while(gr.next()){
users.push(gr.getValue('sys_user'));
}
if(users.length > 0){
gs.eventQueue('art.notify.send', current, users); //replace your event name and the current RITM record.
}
- I do also have Parm1 selected.
Unfortunately, this is not working at all - Ideas? Further guidence?
thank you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 09:40 PM
Hi @Bidduam ,
- Added a new event to the event registry called - art.notify.send
For the above point, you don't need to create flow for it. As this need to be created once only.
So, Navigate to [sysevent_register] table and create with the name 'art.notify.send'
2. The catalog Item which you are using is having a flow or workflow?
If a workflow is attached to it, then you have to use the 'create event' activity
Script for parm1:
(function() {
var users = [];
var gr = new GlideRecord('m2m_sp_status_subscription');
gr.addQuery('cmdb_ci_service', current.variables.u_service);
gr.query();
while (gr.next()) {
users.push(gr.getValue('sys_user'));
}
return users;
}());
This will trigger the event and recipient in parm1
Mark this as Helpful / Accept the Solution if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 10:15 PM
@SN_Learn thanks for the help.
I am using flow designer (not workflow editor), so what I have is a flow step to create the event that is in the event registry - art.notify.send
The create event is as follows:
When it runs the following message shows in the execution details:
Error: Cannot read property "variables" from null,Detail: Cannot read property "variables" from null
I also have tried it without current.variables in front of the variable name and it doesn't error but parm1 is then blank