Remove a specific value from a glide_list field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 12:19 AM
Hello,
I have a glide_list field
from which, after pressing a button (UI Action), I want to remove a certain value.
How could I do?
Thanks ☺
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 12:27 AM
Hi,
Use following script. when you use g_form or current on the glide list field it will return comma separated sys_ids. you need to know which value or sys_id to remove so that you can again set the value in the field.
var arr = ['1','2','3'];
var toBeRemoved = 1;
var tempArr = [];
for(var i=0;i<arr.length;i++){
if(arr[i] != toBeRemoved)
tempArr.push(arr[i].toString());
}
gs.print(tempArr);
use this tempArr to set the value in the glide list again and save the record if you want
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 10:00 AM
Thanks for the code Ankur, this helped me a ton!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2019 10:36 PM
Hi Drew,
Can you also mark the answer as correct and helpful. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2019 01:30 PM
I wasn't the original poster, but I appreciate the help!