I wanted to Update the Notification device primary email to the candidate
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 06:53 AM
Hi All,
Can anyone please help me on the below query please.
for the candidate HR profile email and notification device primary email both are should be same.
if HR profile email is changed notification device primary email should change.
Written this script its not working please help me to achieve this
var hrp = new GlideRecord('sn_hr_core_profile');
hrp.addEncodedQuery(query);
hrp.query();
while (hrp.next()) {
var usrSysID = hrp.getValue("user") + '';
userList.push(usrSysID);
var device = new GlideRecord('cmn_notif_device');
device.addQuery('user', usrSysID);
device.query();
if (device.next()) {
device.email_address = usrSysID.email;
device.update;
}
hrp.addEncodedQuery(query);
hrp.query();
while (hrp.next()) {
var usrSysID = hrp.getValue("user") + '';
userList.push(usrSysID);
var device = new GlideRecord('cmn_notif_device');
device.addQuery('user', usrSysID);
device.query();
if (device.next()) {
device.email_address = usrSysID.email;
device.update;
}
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 09:08 AM
Hi @nikhitha24 ,
Whats query contains in line number 2 , try to print usrSysID as below and see what you get in the logs.
var hrp = new GlideRecord('sn_hr_core_profile');
hrp.addEncodedQuery(query);
hrp.query();
while (hrp.next()) {
var usrSysID = hrp.getValue("user") + '';
gs.info("User id "+" "+usrSysID)
var device = new GlideRecord('cmn_notif_device');
device.addQuery('user', usrSysID);
device.query();
if (device.next()) {
device.email_address = usrSysID.email;
device.update;
}
Accept and hit Helpful if it helps.
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025