returning data from a glide list

dh4234
Kilo Expert

If I have a glide list of locations how do I return the Site Code, City, and State in a mail message? I have not worked with arrays so I am not sure how to extract each location from the array so I can do a look up on each location. Thanks

13 REPLIES 13

Joe_Employee
Tera Contributor

Assign a glide list content to an array variable
Talks about assigning glide list content to an Array

http://wiki.service-now.com/index.php?title=Referencing_a_Glide_List_from_a_Script
Is about about referencing a Glide from a script

http://wiki.service-now.com/index.php?title=ArrayUtil
A potential helpful array utility

Hopefully that gives you a few places to start. Let me know if you're still stuck.

~Joe


dh4234
Kilo Expert

I've got the part where I split the list, but how do I then return the data tied on each location I pulled out?


Joe_Employee
Tera Contributor

While this may not be exactly this was the only other thing I could find close to what you are looking at:
adding the list of CR approvers in email content

Feel free to post your code and/or screen shots any additional information you can provide is always helpful.

~Joe


Mark Stanger
Giga Sage

This should work in a mail script if your location field is 'u_locations'.



var list = current.u_locations.toString();
var array = list.split(',');
for(var i=0; i < array.length; i++){
var loc = new GlideRecord('cmn_location');
loc.get(array<i>);
template.print('Location name: ' + loc.name + '\n');
template.print('Location city: ' + loc.city + '\n');
template.print('Location state: ' + loc.state + '\n');
template.print('\n');
}