How to fill user Id field in received emails (sys_email) based on user id instead of email

pavankumary
Kilo Contributor

Hi All,

we have a requirement where user Id has to be filled based on "user_id field in user table" instead of email id.

In detail, in our instance, user_id field contains the user id in the email id format(abc@xyz.com) and email id(aaa@ced.com) contains the email id. Now all the users sending the emails from the email accounts which are mapping the user Id field in user table (i.e.. from abc@xyz.com) instead of email (aaa@ced.com)

But as per the OOB feature, the User Id field on received emails (sys_email) automatically filled based on mapping the from email address to email field on the user table

But this mapping should be happened based on mapping the from email address to user_id field on the user table

Do we have any OOB feature/property to change this mapping? or please suggest if we have any other way to do the same?

Can we identify where exactly sys_email is updated with the information from email received?

Kindly help us ASAP as it is major business requirement and mails are not processed as expected

Thanks,

Pavan

4 REPLIES 4

lSurya 24
Giga Guru

Hello Pavan,



In whom to send tab in the notification, if you have a reference field referencing to the user table. Pick that one and dot walk to the user id. In that way, I think emails will be sent to the email id which is there in user id.


Hi Surya,



Thanks for your reply,



But my question is different. Actually my question is about filling the User Id field in received emails.



Please navigate to System mailboxes -> Received



Open a record and can view User Id field which is reference to user table.



Currently it is filling based on field "User" on the same table (sys_email) by mapping Email Id. instead, this mapping should be happend based on User Id



Please let us know if you need more information



Thanks,


Pavan


I would be interested to know where the logic is located that determines the value of sys_email.user_id. It appears, from all my investigations to date, that there is logic (somewhere?) that looks up a User record (sys_user), using an initial value in the sys_email.user field. The look up is suggested to occur against the sys_user.email field (using the initial value in sys_email.user). If a record on the sys_user table is located, then a reference to that User record is added to the sys_email.user_id field AND the sys_user.sys_id value is added as a string to the sys_email.user field.

 

Does anyone know where the logic is? Inspecting the actual logic is central to KNOWING the behavior that can be expected.

mukulgupta
ServiceNow Employee
ServiceNow Employee

Hi Pavan,



When an email is received on the instance it grabs the email address (aaa@ced.com) from the FROM header and then looks for the sys_user record corresponding to this email address. Once it finds the sys_user record then it associates the user id (abc@xyz.com) of that sys_user record to the User Id on the sys_email record of the received email --- This is how it works Out of the Box.



If you want the email address (aaa@ced.com) to show up on the User Id on the sys_email record you can navigate to the sys_user table dictionary record and make Email field as the Display value for Reference Tables by checking "Display" flag.


Snip20170829_8.png



NOTE:


> Only one field can be defined as the display value for a table.
> When you set the Display value to true, a business rule sets the Display value to false for all other fields on the table. In previous versions, you must manually ensure that no other fields on the table have a value of true in the Display column.
Ref Documentation: Select a field as the table display value



> By default for the sys_user table if there is no field set as the display value then "name" field is displayed but if we explicitly set "email" as display field then Email will start displaying in all the Reference Tables of the sys_user table.


> If you just want to have the Email field of the user record for your reference on the sys_email record, then you can also do DOT walking from User ID > UserID.email to display the email address of the user on the email record. You can do it from the Configure > Form Layout option.



Snip20170829_9.png



Please feel free to reach out if you have any other questions or concerns.



Thanks!