- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 10:43 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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:03 PM
Hi @Chhavi Dixit ,
First check emails are not duplicate.
Add alerts in client script and check what email its sending to script include
Add alert to check what answer it is returning.
And in script include add gs.info to print this.getParameter('sysparm_email);
And add gs.info after query statement and even before return statement.
Please mark it as helpful/correct if it solves your issue.
Best Regards,
Pooja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:19 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-19-2025 11:03 PM
Hi @Chhavi Dixit ,
First check emails are not duplicate.
Add alerts in client script and check what email its sending to script include
Add alert to check what answer it is returning.
And in script include add gs.info to print this.getParameter('sysparm_email);
And add gs.info after query statement and even before return statement.
Please mark it as helpful/correct if it solves your issue.
Best Regards,
Pooja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:19 PM
HI @Pooja58 ,
CS is sending blank email to script include that is why this issue is happening.
I think the issue is occurring at the Catalog item level.
How to fix it. 😞
Thanks!
Chhavi Agnihotri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:19 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-19-2025 11:45 PM