REQ - defaulting users location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 09:25 AM
I've got an interesting situation where we are wanting to default the user's location into the location field on the REQ view, but i can't edit that field, and its pointing to the task table for some reason.
has anyone come across this, and found a work around?
the location field actually pulls the sys_user table from what i can see. when i attempt to modify the dictionary entry, it wont let me select a diff table either.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:52 AM
Hi @CamUnderwood ,
its an incorrect reference to the location field, you should be able to change to "cmn_location" table are u getting any error/info message during reference change
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 11:47 AM
Hi @CamUnderwood ,
Hope you are doing great.
The first step is to create a Business Rule that triggers when a new REQ record is created. This Business Rule will automatically populate the location field with the user's location.
- Create a new Business Rule named "Populate Location on REQ Create."
- Set the "Table" field to "REQ" to target the REQ table.
- Set the "When to run" field to "Before" and "Insert" to trigger the rule when a new record is created.
try using below script for reference :
(function executeRule(current, previous) {
// Check if the location field is empty
if (!current.location) {
// Get the current user's sys_user record
var currentUser = gs.getUser();
var userLocation = currentUser.getLocation();
// Set the user's location as the default value for the location field on REQ
if (userLocation)
current.location = userLocation;
}
})(current, previous);
Regards,
Riya Verma