Need to remove a particular value from the glide list

Heisenberg
Tera Contributor

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);
}

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

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

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

Thanks mate! This made my day

Prasant Kumar 1
Kilo Sage

Hi,

Can u please explain your requirememt so that i can suggest you.

Thanks & Regards,

Prasant kumar sahu