- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:03 AM
There are 2 tables
sys_user
s1(custom table)
here user is referencing the sys_user table
I want to auto populate email when user was selected
I have written some code but it is not working why....?
Can anyone help
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:11 AM
Hi @Phani Pasupulet ,
I would suggest using GlideAjax, as getReference has performance impacts.
Even if you choose to use GetReference, use it with callback function.
var user = g_form.getReference('u_reference_4', getEmail); // doAlert is our callback function }
function getEmail(user) { //reference is passed into callback as first arguments
g_form.setValue('u_string_2',user.email);
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:24 AM
Why not add the email field as Dot walked field on form fromt he User Name field and make it readonly?
Then no script is required
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:11 AM
Hi @Phani Pasupulet ,
I would suggest using GlideAjax, as getReference has performance impacts.
Even if you choose to use GetReference, use it with callback function.
var user = g_form.getReference('u_reference_4', getEmail); // doAlert is our callback function }
function getEmail(user) { //reference is passed into callback as first arguments
g_form.setValue('u_string_2',user.email);
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:24 AM
Why not add the email field as Dot walked field on form fromt he User Name field and make it readonly?
Then no script is required
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:37 AM
I auto populated ph no
why I am gettting number as above format
even when I updating the abel number it is taking in the same format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 02:39 AM
Ph no is of what type? It looks it's string type.
The format comes based on how it's stored in sys_user record
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader