How to populate First and last name on the basis of email

Chhavi Dixit
Tera Contributor

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:

ChhaviDixit_0-1740033769999.png

 

Client script:

ChhaviDixit_1-1740033770039.png

 

I am getting below data:

 

ChhaviDixit_2-1740033769655.png

 

 

Please help me guys.

 

Thanks in advance 

ChhaviDixit_3-1740033769657.png

 

 

Thanks!

Chhavi Agnihotri

2 ACCEPTED SOLUTIONS

Pooja58
Kilo Sage

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

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Chhavi Dixit 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Pooja58
Kilo Sage

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

HI @Pooja58 ,

 

CS is sending blank email to script include that is why this issue is happening.

 

ChhaviDixit_0-1740035765031.png

 

ChhaviDixit_1-1740035847739.png

 

I think the issue is occurring at the Catalog item level.

How to fix it. 😞

 

Thanks!

Chhavi Agnihotri

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Chhavi Dixit 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you so much @Ankur Bawiskar  🙂

Yes, its working fine.

 

🙂