User's email address on user record does not reflect on their primary email record

Sofija
Giga Expert

Hi All,

We have an issue where users are not receiving emails from ServiceNow because their email (on sys_user table) has been updated but this update has not been reflected under their primary email address (which is used for sending email notifications). Therefore, emails are being sent to the old email address The issue occurs when user email gets updated on user record but it does not get reflected on their primary email. We are not not sure how many users are not receiving their emails because their primary email and the one on their user record do not match.

1) Did anyone encounted this type of problem previously and have any suggestions on how to resolve it? We also logged HI ticket for this.

2) Does anyone know where the primary email lives (on which table)? We want to run reports that would show all users whose primary email is different from the one on their user record (we tried to create one but we cannot locate the table on which the primary email information lives).

Any thoughts and suggestions are appreciated!

Kind Regards,

Kamile

1 ACCEPTED SOLUTION

On your transform map, is below check box ticked?



find_real_file.png


View solution in original post

18 REPLIES 18

Hi Kamile,



I tried reproducing the given scenario (1) but I cannot. Whenever a new sys_user record is created / updated below OOB business rules execute:



Create primary email device


Update Email Devices



And, these scripts keep the data in sync in table cmn_notif_device. Have you tried reproducing it in your instance? Or else, I would suggest you creating a debug business rule on sys_user table and capture logs. It must help you fixing it.



Brgds, AM


I tried reprocuding the issue and I can do it on all of our instances. I routed this issue to ServiceNow as something seems to be broken. We never edited the rule and the records show up as updated, yet the rule does not run. Thank you for your effort! This seems to be impacting just us..


Wow...it seems to be interesting now!!!



If you don't mind, can you please share both of below Business Rule scripts:



Create primary email device


Update Email Devices



Along with the script code, also please let us know when the business rule runs e.g. before/after and insert/update etc.


Would be glad if I can assist you any further


Sure - here are both of the business rules:



1. Create primary email device


When to run: after Insert (no additional conditions)


Script:


var thisSysID = current.sys_id;


var device = new GlideRecord('cmn_notif_device');


device.user = thisSysID;


device.email_address = current.email;


device.primary_email = true;


device.active = true;


device.type = 'Email';


device.name = 'Primary email';


device.insert();


gs.addInfoMessage(gs.getMessage('Primary email device created for') + ' ' + GlideStringUtil.escapeHTML(current.name));



2. Update Email Devices


When to run: after Update


Condition: current.email.changes() || current.notification.changes()


Script:


var thisSysID = current.sys_id;


var device = new GlideRecord('cmn_notif_device');


device.addQuery('user', thisSysID);


device.addQuery('type', 'Email');


device.query();


while (device.next()) {


    if (device.primary_email == true)


          device.email_address = current.email;


    if (current.notification.changes()) {


          if (current.notification == 2)


                device.active = true;


          else


                device.active = false;


    }


    gs.log('Updating ' + current.name + 's email devices based on change to user record email address or Notification field');


    device.setWorkflow(false);


    device.update();


}


Kamili,



I have reviewed both the scripts and they are fine. Difficult to make any guess further without looking into the instance but, I have one more suggestion perhaps it can help you.


Have you tried using System Diagnostics e.g. debug business rules etc.? May be it can get you any further clue otherwise wait for HI support feedback.


Please let us know when you come up with any findings...



Brgds, AM