send notification to users in related list

IceIronDragon
Tera Guru

Hello All,

 

We have a requirement where in notifications should go to all the affected users in the related list not just one in the Affected user field on the form.Whats happening right now is the notification is only being sent to the person in affected user field, not for multiple users in the related list

 

IceIronDragon_0-1669132917546.png

 

IceIronDragon_1-1669132955271.png

 

 

1 ACCEPTED SOLUTION

use below script in mail script. Glide Proper table which is present on related list and field names.

 var gr = new GlideRecord("Related list table Name");
    gr.addQuery("task", current.sys_id);
    gr.query();
    while (gr.next()) {
        email.addAddress("cc", gr.user.email, gr.name);
    }

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

11 REPLIES 11

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @IceIronDragon 

You can actually glide the user's list in the mail script and add all of them in cc.

Steps to create Email Script and how to use:

  1. Navigate to the "Notification email Script" in the "System Notification" in filter navigator.
  2. Set the name of email notification "add_newusers_to_cc".
  3. add below code in the script: You can glide related list table and fetch email ID's from their
 email.addAddress("cc","email_address_of_the_user","Name_of_ther_user");
//if you want to push the user dynamically then you can use the scripting to validate and push the user.

4. Now navigate to the notification where you want to add cc.

5. add "${mail_script:add_newusers_to_cc}" in "Message HTML" field in "What it will contain" form section of notification.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

IceIronDragon
Tera Guru

We are looking for a dynamic solution.

Where in anyone could be added to the affected user related list and they receive the notification whn meeting conditions. 

How to do we proceed with ?

Hi @IceIronDragon ,

That is dynamic solution only. You will have to glide that table and fetch users from that related list and add them dynamically using loop.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

IceIronDragon
Tera Guru

I understand , are we still using notification email script ?