- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 06:45 AM
We have a glide list field on Incidents for tracking the groups involved. I would like to pick off the first value from that list and use it in a breakdown mapping. Below is what I have so far, but not sure I am on the right track. How do I write the script to only bring back the first value in the list?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 07:07 AM
You are close, you just need to drop the loop since you just want the first value.
(function(){
if(current.u_glide_list_1){
var groups = ("" + current.getValue("u_glide_list_1")).split(",");
if(groups.length > 0){
var gr = new GlideRecord("sys_user_group")
if(gr.get(groups[0])){
gs.log(gr.getValue("name"));
return groups[0]; //This will return the sys_id of the group.
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 07:07 AM
You are close, you just need to drop the loop since you just want the first value.
(function(){
if(current.u_glide_list_1){
var groups = ("" + current.getValue("u_glide_list_1")).split(",");
if(groups.length > 0){
var gr = new GlideRecord("sys_user_group")
if(gr.get(groups[0])){
gs.log(gr.getValue("name"));
return groups[0]; //This will return the sys_id of the group.
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 07:23 AM
Thank you for the quick response! I tried it out am getting the following error below. Any ideas?
Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments" script: (function(){
if(current.u_glide_list_1){
var groups = ("" + current.getValue("u_glide_list_1")).split(",");
if(groups.length > 0){
var gr = new GlideRecord("sys_user_group");
if(gr.get(groups[0])){
gs.log(gr.getValue("name"));
return groups[0]; //This will return the sys_id of the group.
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 07:39 AM
Nevermind.....got it to work! Thanks for your help 😊
(function(){
if(current.u_glide_list_1){
var g = current.u_glide_list_1;
var groups = g.split(",");
if(groups.length > 0){
var gr = new GlideRecord("sys_user_group");
if(gr.get(groups[0])){
gs.log(gr.getValue("name"));
return groups[0]; //This will return the sys_id of the group.
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
})();