I wanted to Update the Notification device primary email to the candidate

nikhitha24
Tera Guru

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;
}
1 REPLY 1

Hemanth M1
Giga Sage
Giga Sage

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