Need an example of how to get reference field and auto-populate a field

Lexle
Tera Contributor

Hello, I need some guidance as I have never used glideAjax() before. I need to get two reference fields in order to auto-populate fields on the catalog client script. 

My scenario:

Catalog Client script -

  • need floor and building fields (user reference fields) to auto-populate based on script includes reference fields.
  • There is a 'requested for' field that references the user table.

Script includes-

  • need floor and building reference field sys_id's based on user sys_id.
2 REPLIES 2

Najmuddin Mohd
Mega Sage

Hi @Lexle ,
If your requirement is to populate the user's fields on selection of a user, then you do not require Client script and GlideAjax. It can done by using the OOB feature 'Auto populate' in the variable creation.

 

NajmuddinMohd_0-1723830769427.png

 

First I created first a Requested for field.

Second, I created a department field with Reference as cmn_department table and selected Auto Populate tab. Here we define on which field is the dependency is. Select the filed created(Requestd for). It now points to the User table.

Third select the field that you want to populate in the created field.
It's done.


NajmuddinMohd_1-1723831098504.png


You can also go through the below link to understand GlideAjax.
https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430



If this information helps, kindly mark it as Helpful and Accept the solution.

Regards,
Najmuddin.

ShubhamGarg
Kilo Sage

Hello @Lexle ,

Here is the link to an example of GlideAJAX call with Client Script . Hope it helps.

 

If my response helps you in any way, kindly mark this as Accepted Solution/Helpful and help in closing this thread.

Regards,

Shubham