- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 05:49 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 09:27 PM
Those who replied and helped were really appreciated. Thanks all for that !! @Murthy Ch @Sharanya Hegde3 @Mohit Kaushik
This issue has been fixed now by referring OOB emai script "pwd.enrollment_reminder". We dont need to check array length and no need to pass array data with counter in addquery which was causing this issue (Still not sure of logic behind this). Refer to the updated piece of code for reference.
Happy Learning from mistakes !!!
var app = grKri.ABC.approver.split(",");
var appuser = new GlideRecord("sys_user");
appuser.addQuery("sys_id",app);
//appuser.addQuery("notification", 2); //email
//appuser.addQuery("email", "!=", "");
gs.info("in submit script 4 tostring " + app);
appuser.query();
while (appuser.next()) {
var mail = appuser.email.toString();
var name = appuser.getDisplayValue();
gs.info("in submit user email: " + mail);
gs.info("in submit user name: " + name);
email.addAddress("cc", mail, name);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 09:00 AM
Hi @MPP22,
Can you try below change in your script?
user.addQuery("sys_id", app[i].toString());
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 06:34 AM
Hi @MPP22 ,
You can try using this:
var user = new GlideRecord('sys_user');
user.addQuery("sys_id", 'user sys id');
user.query();
while (user.next()) {
email.addAddress('cc', user.email, user.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 08:06 AM
Hi @MPP22 ,
Are you setting something in recipients as 'TO'? If you are not doing that then with script your cc options will not appear, and the notification will not go to them. Please check for that. 'To' field should not be empty in the notification. If you are setting the values automatically, then probably you can use events to set the recipients as To and remaining things through your mail script.
Please mark this answer as correct and helpful as per the impact.
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 08:14 AM
@Mohit Kaushik Yes Am setting directly in TO via Notification. In email logs can see email triggered to "TO" successfully. Issue is with "CC" dynamic email address.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 09:27 PM
Those who replied and helped were really appreciated. Thanks all for that !! @Murthy Ch @Sharanya Hegde3 @Mohit Kaushik
This issue has been fixed now by referring OOB emai script "pwd.enrollment_reminder". We dont need to check array length and no need to pass array data with counter in addquery which was causing this issue (Still not sure of logic behind this). Refer to the updated piece of code for reference.
Happy Learning from mistakes !!!
var app = grKri.ABC.approver.split(",");
var appuser = new GlideRecord("sys_user");
appuser.addQuery("sys_id",app);
//appuser.addQuery("notification", 2); //email
//appuser.addQuery("email", "!=", "");
gs.info("in submit script 4 tostring " + app);
appuser.query();
while (appuser.next()) {
var mail = appuser.email.toString();
var name = appuser.getDisplayValue();
gs.info("in submit user email: " + mail);
gs.info("in submit user name: " + name);
email.addAddress("cc", mail, name);
}