
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 12:20 PM
I have a requirement that if a certain subcategory is selected I need to add two users to the watch list along with anybody already on it. I have this working from a business rule. I now need be able to remove these users if that subcategory is changed to anything else. I'm not sure how to code the removal of the users from the watch list. Any help would be appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 02:12 PM
Here you go. Leverage OOB arrayUtil for this
var arrayUtil = new ArrayUtil();
var subCatArr = ["sys_id1", "sys_id2"];
var watchlistArr = current.watch_list.toString().split(',');
current.watch_list=arrayUtil.diff(watchlistArr,subCatArr).join();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 12:51 PM
Are those the same two users, which are added, you want to remove? If yes, then i think you can have an array to save all the wtachlist users except those two users which you want to remove then set the value of array to watchlist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 01:24 PM
Sample code,
var nwl = [];
var wl = current.watch_list.toString();
var wla = wl.split(',');
for(var i = 0; i < wla.length; i++){
if(wla[i] != 'SYS_ID of the user you want to remove')
nwl.push(wla[i]);
}
current.watch_list = nwl.toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 02:12 PM
Here you go. Leverage OOB arrayUtil for this
var arrayUtil = new ArrayUtil();
var subCatArr = ["sys_id1", "sys_id2"];
var watchlistArr = current.watch_list.toString().split(',');
current.watch_list=arrayUtil.diff(watchlistArr,subCatArr).join();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 04:52 AM
Thanks that worked perfectly.