Glide list data type

Kasi Ramanathan
Kilo Guru

 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]);
}
1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

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

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

2 REPLIES 2

Anil Lande
Kilo Patron

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

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader