Primary Email Mismatch

LiamO
Tera Contributor

Hello! 

 

It has been discovered that there is an email address mismatch between sys_user email and cmn_notif_device email_address for some of our users. 

 

If we manually update an email address within the sys_user table, the business rule 'Update Email Devices' runs perfectly to update the cmn_notif_device email_address field. 

 

We have found the below post from quite a few years ago, that is very similar to what we are experiencing but their script doesn't solve our problem as email_address from cmn_notif_device is not empty.

 

Solved: Re: Update email addresses for all users - ServiceNow Community

 

Unfortunately scripting is not part of our skill set (it's on the to-do list)...

 

Hoping someone will be able to assist with a script or a workaround to get cmn_notif_device to match sys-user email addresses. 

 

And sorry if I post this on the wrong board... 

 

- Liam

6 REPLIES 6

phgdet
Mega Sage

Hi LiamO, check this code.

var current = new GlideRecord("cmn_notif_device");
current.addEncodedQuery('email_addressNSAMEASuser.email'); // add your query for mismatch list, unless it will run all records;
current.setLimit(20); // limit 20 for testing, remove if you dont need that 
current.query();
while(current.next()){
    if(current.user && current.user.email){
        var userEmail = current.user.email;
        current.setValue('email_address', userEmail);
        current.update();
    }

}



Ankur Bawiskar
Tera Patron
Tera Patron

@LiamO 

you can use the same script in background script or I will suggest to use fix script

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader