The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Notifications Dynamic Who Will Receive

stevejarman
Mega Guru

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();

}

1 ACCEPTED SOLUTION

Ahmmed Ali
Mega Sage

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:


find_real_file.png



notification form :


find_real_file.png



Please note : Above is the advanced view. the option is not available under default view.



Please let me know for any query.



Thanks,


Ali


If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

4 REPLIES 4

Ahmmed Ali
Mega Sage

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:


find_real_file.png



notification form :


find_real_file.png



Please note : Above is the advanced view. the option is not available under default view.



Please let me know for any query.



Thanks,


Ali


If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

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.


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?

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?