How to populate First and last name on the basis of email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 10:18 PM
HI Everyone,
How to populate First and last name on the basis of email selected in Catalog Item.
I have created script include (via javascript object) and client script but I am getting wrong first name and last name, every time its showing virtual agent however emaild id is empty for virtual agent user.
Script Include:
Client script:
I am getting below data:
Please help me guys.
Thanks in advance 🙂
Thanks!
Chhavi Agnihotri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 05:47 PM
Did you keep logs in server side script and see which user record is returning?
Hope you are given the correct variable name for email.
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 06:18 PM
@Arsh Agnihotri Looks like the name of your email field is incorrect. It seems that line number 6 in your client script is returning empty value hence the query in script include is fetching a record where email is empty.
var userEmail=g_form.getValue('email'); //Please veify if the email is the correct name for the email field on the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 06:46 PM
I could see Email is a reference variable then why not use auto populate feature with no scripting
Auto-populate a variable based on a reference type variable (Utah)
Since your variable is reference you should query with sysId and not email
Update this line in script include
user.addQuery('sys_id', email);
Also in GlideAjax update this line as this
ga.addParam('sysparm_email' , newValue);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2025 04:13 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader