
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 06:07 AM
I need to print the latitude and longitude of list type reference field. Kindly help on the script.
var list = gr.u_impacted_locations.toString();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
var location = array[i];
gs.log(location.longitude);
gs.log(location.latitude);
//gs.log("Display value is: " + array[i]);
}
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 06:11 AM
Hi,
As u_impacted_locations is Glide List (List field), you only get sys_id's of selected records there.
you need to Glide to get record details.
update your script like:
var list = gr.u_impacted_locations.toString();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
var location = new GlideRecord('cmn_location');
location.get(array[i].toString());
gs.log(location.longitude);
gs.log(location.latitude);
//gs.log("Display value is: " + array[i]);
}
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 06:11 AM
Hi,
As u_impacted_locations is Glide List (List field), you only get sys_id's of selected records there.
you need to Glide to get record details.
update your script like:
var list = gr.u_impacted_locations.toString();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
var location = new GlideRecord('cmn_location');
location.get(array[i].toString());
gs.log(location.longitude);
gs.log(location.latitude);
//gs.log("Display value is: " + array[i]);
}
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 06:26 AM
Hi,
Please provide details on on which table that glide list field is present? to which table it refers
you can directly print the display value like this
var list = gr.u_impacted_locations.getDisplayValue();
Also assuming your list field refers to cmn_location table you need to iterate over all the sys_ids
var list = gr.u_impacted_locations.toString();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
var gr = new GlideRecord("cmn_location");
if(gr.get(array[i])){
gs.info(gr.longitude);
gs.info(gr.latitude);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader