How Can I autopopulate 'Location' Reference field with same value as shown in Space Reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 12:18 AM
How Can I auto-populate 'Location' Reference field with same value as shown in Space Reference field
Hi Guys,
I have built a few Reference fields, Building (u_building), Floor (u_floor) and Space (u_space) field on my Incident Form (see screenshot attached). These are all Reference fields.
These are all driven/referenced directly from the Location (cmn_location) table.
I also have the standard 'Location' field, which also references the Location table.
How can I write either a script or business rule, so that when the Space (u_space) field gets populated with a location value, at the same time the Location (location) field will then also get updated with the same location value, that is referenced within the 'Space' (u_space) field ?
I assume this is either a Business Rule or perhaps onChange Client Script?
Please see my screenshot attached, showing the relevant fields.
I would appreciate any help/guidance with achieving this.
Many Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 12:57 AM
Hi @WazzaJC , I assumes that you store Buildings, Floors and Spaces also as Location record utilizing parent field to build up an Hierarchie, or not?
I would use a onChange Client Script to populate the other fields (build a nice GlideAjax which delivers all locations which should be populated onChange), so that you provide the change directly on form as soon as location is switched. With BRs you need to click on submit or save first.
Greets
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 02:39 AM - edited 06-09-2023 02:41 AM
I suggested the dictionary record solution to avoid client script/Business rules code, but yeah I agree with @Daniel Borkowi1 Use onChange client script for better user experience and GlideAjax is not required as both space and location fields are referenced directly from the location table, just try the following one-line code in the onChange client script on the space field
g_form.setValue('location', newValue); //newValue is the current value in Space field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 02:44 AM
Thank You Sai - I will try this out.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 03:01 AM
Yes you're right with the Ajax, I already thought a step further on. If you also want to populate Building and Floor if you select the space. In this case you need to walk up the location hierarchy. But @Sai Kumar B you're complete right, if only location needs to be the same like space, than your script is enough - no need of GlideAjax.