- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 03:59 AM
Hi,
Im trying to show a list of options under Location field when creating a new user in sys_user table.
What am I doing wrong?
getLocations: function() {
var arr = [];
var gr = new GlideRecord("cmn_location");
gr.addQuery();
gr.query();
while(gr.next()) {
arr.push(gr.getValue('name'));
}
return arr.toString();
},
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 04:24 AM
1. Please update your script to return array of sys_id
getLocations: function() {
var arr = [];
var gr = new GlideRecord("cmn_location");
gr.addQuery();
gr.query();
while(gr.next()) {
arr.push(gr.getValue('sys_id'));
}
return arr.toString();
}
2. Update your reference qualifier to 'sys_idIN'+new CSManagementUtils.getLocations();
then check.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 04:08 AM
What exactly do you want to show? This query indeed isn't going to show anything. Please provide us with the requirement so we can help creating the correct one.
If my answer helped you in any way, please then mark it as helpful.
Mark
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 04:13 AM
hi Mark,
im trying to show location values from cmn_location table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 04:26 AM
You script include is just getting all locations in the system, so why do you need a reference qualifier at all?
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 04:24 AM
1. Please update your script to return array of sys_id
getLocations: function() {
var arr = [];
var gr = new GlideRecord("cmn_location");
gr.addQuery();
gr.query();
while(gr.next()) {
arr.push(gr.getValue('sys_id'));
}
return arr.toString();
}
2. Update your reference qualifier to 'sys_idIN'+new CSManagementUtils.getLocations();
then check.
Thanks & Regards,
Vasanth