- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 10:53 AM
Good Day,
i am trying to figure out a Client script for onLoad to have the user who is opening the form, their Location to be automatically added to the Location on the form
Ex.
so who ever logs into the form, their Office location (cmn_location) will be automatcally filled in this field. (u_office_orgin_location)
Both the Sys_user location and this Office location is a reference field that is pulling from the same table cmn_location
any help is appricated
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 01:05 AM
So logged in user's location should be auto-populated in the variable/field?
you can use default value in that field
javascript: gs.getUser().getLocation();
What did you try so far and what didn't work? What did you debug?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 12:37 AM
Hello @Peter Williams
Please refer to these community posts below.
- I am trying auto populate user location on load of a record producer . using this script but it is n...
- Populate Location Field onLoad - Request-By and onChange - Requested-For
- onChange Catalog Client Script setting Location # Field
- Auto populate the location based on user's location.
- Set Location for caller on initial load only
You might also want to check -
User Object Cheat Sheet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 01:05 AM
So logged in user's location should be auto-populated in the variable/field?
you can use default value in that field
javascript: gs.getUser().getLocation();
What did you try so far and what didn't work? What did you debug?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 05:09 AM
i tried that and its working
thank you