Need to remove a particular value from the glide list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 06:26 AM
Hi,
Can some one guide me what is wrong in this script trying to remove particular value from the glide list field not working, please advice.
var gr = new GlideRecord('user_criteria');
gr.addEncodedQuery('name=UC_VISIO');
gr.query();
if(gr.next()){
var arr = gr.u_financial_cost_center.split(',');
gs.log(arr);
var pos = arr.indexOf('8aca5979db36df00494a16d15b9619cb');
arr.splice(pos,1);
gr.update();
gs.log(arr);
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 06:40 AM
Hi,
update code as below and it should work
you are not setting the values in that field; also use gs.info() and not gs.log()
var gr = new GlideRecord('user_criteria');
gr.addEncodedQuery('name=UC_VISIO');
gr.query();
if(gr.next()){
var arr = gr.u_financial_cost_center.toString().split(','); // convert to array
gs.info(arr);
var pos = arr.indexOf('8aca5979db36df00494a16d15b9619cb');
arr.splice(pos,1);
gr.u_financial_cost_center = arr.toString();
gr.update();
gs.info(arr);
}
Mark ✅ Correct if this solves your issue and also mark 👍 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
12-15-2021 01:54 AM
Thanks mate! This made my day

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 06:46 AM
Hi,
Can u please explain your requirememt so that i can suggest you.
Thanks & Regards,
Prasant kumar sahu