Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Email notifications

SingL
Tera Contributor

I have configured few email notifications to trigger after request got fulfilled. This is triggering based upon the variable choices user selects. 

Now I want to send emails to few users who are in the list collector variable. So they will receive confirmation emails once the request got fulfilled. 

i am

trying to implement using email script but it’s only pulling them in cc but not in To field. 

 

experts please help. Thank you!

 

 

3 REPLIES 3

Its_Azar
Tera Guru
Tera Guru

Hi there @SingL 

 

If you want to send the notification to the users in the list collector, don't rely on the To field UI — list collector values don't automatically populate there.  else just select the variable in Recipients fields which holds list collector , in your notification, go to Recipients → Advanced and use 

(function() {
    var users = [];
    var listValues = current.variables.your_list_collector_variable; // sys_ids

    if (listValues) {
        listValues.split(',').forEach(function(id) {
            users.push(id);
        });
    }

    return users;
})();

This will send the email directly to those sys_ids as primary recipients, not CC.

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG

SingL
Tera Contributor

I used debugging to check in the email logs and it displayed all the users email to whoever I have given. But that did not show those users in the To or recipient field of email logs. So should I confirm that it still works as per your comment? 

SingL
Tera Contributor

I tried it did not work. Can you please help me on this?