The Now Platform® Washington DC release is live. Watch now!
01-08-2018 07:08 PM
Does anyone know of a built-in/out-of-box method for configuring a Notification to send to dynamic recipients?
Under the "Who will receive" tab, you seem to only have the option to send to a specified list of Users and/or Groups.
In my case, I have a Notification that is triggered by an Event, and I'd like that Notification to send to all staff members in my organisation (every active user account with an our company.com.au address).
I'm doing this currently by having a group defined called "All Staff" which is populated by a scheduled script (see below). I can then use the "All Staff" group for the Notification "Who will receive" list. This just seems like a really hacky way to do this though.
Is there a better/easier/cleaner way?
// DELETE ALL EXISTING ENTRIES IN THE GROUP
var rs1 = new GlideRecord("sys_user_grmember");
rs1.addQuery("group", "f567952d4fe38b40017720201310c761"); // All Staff
rs1.query();
while (rs1.next())
{
rs1.deleteRecord();
}
// ADD ALL STAFF
var rs2 = new GlideRecord("sys_user");
rs2.addQuery("email", "CONTAINS", "ourcompany.com.au");
rs2.addActiveQuery();
rs2.query();
while (rs2.next())
{
var rs3 = new GlideRecord("sys_user_grmember");
rs3.newRecord();
rs3.user = rs2.sys_id.toString();
rs3.group = "f567952d4fe38b40017720201310c761"; // All Staff
rs3.insert();
}
Solved! Go to Solution.
01-08-2018 11:21 PM
Hi Steve,
You can pass the recipient user's sys Id (comma separated string) in either of the event parameter. then in notification, check the relevant checkbox under "who will receive" tab.
Below is the screenshot for reference.
script to fire the event:
notification form :
Please note : Above is the advanced view. the option is not available under default view.
Please let me know for any query.
Thanks,
Ali
01-08-2018 11:21 PM
Hi Steve,
You can pass the recipient user's sys Id (comma separated string) in either of the event parameter. then in notification, check the relevant checkbox under "who will receive" tab.
Below is the screenshot for reference.
script to fire the event:
notification form :
Please note : Above is the advanced view. the option is not available under default view.
Please let me know for any query.
Thanks,
Ali
01-09-2018 08:46 PM
Much appreciated. One of my colleagues actually suggested it too at almost the same time you were replying
I'd forgotten about event parameters.
All up and running.
06-03-2021 04:22 AM
I am having the same query but mine is somewhat different.
I want to dynamically send the email when a record is inserted in a table to the user in the caller field of the table.
How can i add the user on the basis of caller field to the Who will receive section?
06-03-2021 04:22 AM
I am having the same query but mine is somewhat different.
I want to dynamically send the email when a record is inserted in a table to the user in the caller field of the table.
How can i add the user on the basis of caller field to the Who will receive section?