Autofill Catalog Item field

Ehab Pilloor
Mega Sage

Hi everyone,

I want to autofill fields for a Library Card Catalog Item in my PDI when a student is selected in Student Name field.

Following fields are to be auto populated: Email and mobile number. How to achieve this?

 

1 ACCEPTED SOLUTION

Ubada Barmawar
Giga Guru

Hi Ehab,

you can create a catalog client script(Onchange) for the variable set containing above variables. the below script will definitely help you fulfill your task.

 

function onChange(control, oldValue, newValue, isLoading)

{

if (isLoading || newValue == '')

{

return; }

 

var student_ref = g_form.getReference('student_name');//get sys_id of entered student

alert(student_ref);//alert for the confirmation

g_form.setValue('mobile_phone',student_ref.mobile_phone);//set the values on catalog variables from the obtained object 

g_form.setValue('email',student_ref.email);

 }

 

 

hope this helps.

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Ehab Pilloor 

 

You can use Auto Populate on variable. 

 

https://www.servicenow.com/community/developer-articles/auto-populate-a-variable-based-on-a-referenc...

 

Share screen shot for more details. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ubada Barmawar
Giga Guru

Hi Ehab,

you can create a catalog client script(Onchange) for the variable set containing above variables. the below script will definitely help you fulfill your task.

 

function onChange(control, oldValue, newValue, isLoading)

{

if (isLoading || newValue == '')

{

return; }

 

var student_ref = g_form.getReference('student_name');//get sys_id of entered student

alert(student_ref);//alert for the confirmation

g_form.setValue('mobile_phone',student_ref.mobile_phone);//set the values on catalog variables from the obtained object 

g_form.setValue('email',student_ref.email);

 }

 

 

hope this helps.

Maik Skoddow
Tera Patron
Tera Patron

Hi @Ehab Pilloor 

please watch the following small video so learn how to manage this without any coding: https://www.youtube.com/watch?v=IMLdnF7ufOg 

Maik