Show data on a form from another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 05:18 AM
I'm trying to pull related data from one table onto the form for another table. I've been reading over previous similar posts but still having trouble. I'm new to scripting so I can't quite interpret what I'm reading to adapt it to my needs. Here's what I'm trying to achieve:
Whenever I create a new hardware model entry into the system, it is assigned a category. On the equipment form, I want to show display that category when the model is selected.
I would really appreciate if someone would break it down for me with some context explanation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 06:14 AM - edited 10-05-2022 06:15 AM
Hi Jamie,
I'm assuming that you've already created the field on your form. What you need to do is have an on change client script. In the absence of an on load, on change does both. Your script will issue an AJAX call to a function that you have written to get the value in question. When it gets that value it will populate the field on your form via g_form.setValue().
The function you call via AJAX will be in a script include that has the client callable checkbox checked.
The documentation is pretty good. Unfortunately we are not able to embed full links in the new community so hopefully you can copy/paste this adding the https:// prefix.
docs.servicenow.com/bundle/rome-application-development/page/script/ajax/topic/p_AJAX.html
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 12:28 PM
I gave this a read through a few times and tried to work something up from it but wasn't successful. Maybe I just need to do some more studying before I can figure it out.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 02:43 PM
Hi Jamie,
unfortunately I don't understand the scenario. What you mean by equipment form?
Usually when you want to connect some data together, I can think of 4 methods:
- Add a field from other table to the same form, you can dot-walk, example: Incident table has reference to user, you can show user.manager on the incident form
- Use before insert business rule. If you need to fill in some field from different table, use this before BR, it can query different record and save it to your current table.
- Use on Display business rule and client script. When you open the form, display BR can query any record and save it in g_scratchpad. By client script you can access scratchpad and fill in any field in your currently opened form. Be aware the value is not dynamic and is only valid at the moment the form is opened and the display BR reads the data.
- Use of GlideAjax, this is real-time query and has been already mentioned.
As said, it is not clear for me what you want to achieve hence I cannot recommend which one would be the best for you. If you can elaborate a bit more, that would be great
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 07:08 AM
I will try to be more descriptive since I am still unable to figure this out despite more studying.
I'm working with hardware equipment records. I have a table of model records. As an example, a CRF 2500. This particular type of hardware is a power supply. So on the model record, there is a field for category where I put that information. Category is a reference field to another table. When I create a new record for an individual piece of hardware and select the model of equipment, I want the system to pull the category information from the model record and populate the category field on the hardware record.
To put it another way, I select category "power supply" from a reference list of categories when I create a model record. When I create a hardware record, I select model CRF 2500 from a reference list. I want the hardware category field filled in with the category I selected for the model.
I hope that helps clear things up.