Need an example of how to get reference field and auto-populate a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2024 08:25 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2024 11:00 AM
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.
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2024 11:15 AM
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