- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 07:38 AM
Good day!
How can I remove/delete a value from a list type field.
I have this line of code (BR):
var updated_users = current.u_alternates.split(",");
where: updated_users=9dcc49ce59a3300005f195d0601f5ab3,donald.duck@disney.com,d1cc49ce59a3300005f195d0601f5ad6
these are sys_ids from sys_user table.
What I wanted to do is to loop and check each value and if it didn't find a match on the sys_user table, I wanted to remove from the updated_users variable.
for(var i = 0; i < updated_users.length; ++i){
var found = false;
var grNew = new GlideRecord('sys_user');
grNew.addQuery('sys_id', updated_users[i]);
grNew.query();
while (grNew.next()){
found = true;
}
if (found == false){
// I need a statement/systax how to remove this entry from the updated_users[]
}
Appreciate all your input.
Thanks,
Enrique
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 07:51 AM
Your almost there..small changes in your script here and there..
var filter =[];//array in which all the valid Sys_id exist
for(var i = 0; i < updated_users.length; ++i){
var found = false;
var grNew = new GlideRecord('sys_user');
grNew.addQuery('sys_id', updated_users[i]);
grNew.query();
while (grNew.next()){
found = true;
}
if (found == true){//if you find a match, then push it to the filter array
filter.push(updated_users[i]);
}
current.u_alternates = filter.toString();//set the filterarray values to the list
}//end of for loop
Thank you,
Aman Gurram

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 07:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 07:51 AM
Your almost there..small changes in your script here and there..
var filter =[];//array in which all the valid Sys_id exist
for(var i = 0; i < updated_users.length; ++i){
var found = false;
var grNew = new GlideRecord('sys_user');
grNew.addQuery('sys_id', updated_users[i]);
grNew.query();
while (grNew.next()){
found = true;
}
if (found == true){//if you find a match, then push it to the filter array
filter.push(updated_users[i]);
}
current.u_alternates = filter.toString();//set the filterarray values to the list
}//end of for loop
Thank you,
Aman Gurram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2018 04:33 AM
Thank you Ajaykumar and Aman for your input.
Enrique