- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 12:06 AM
Hi,
I have a request where we need to add 2 users to watchlist by default to new case created for a pareticular account(assume X) everytime .I was able to fulfill that with a buisness rule w/o any script .
Now we have to append the BR logic to accomadate the below points .
a) These 2 Contacts are added to WList in any scenario that the Case updates to "X" & anyone who already was on the WList before this update event remains on the WList.
b) These 2 Contacts are removed from WList if Case 'Account' is changed FROM "X" & anyone who already was on the WList before this update event remains on the WList.
This is the script logic I have in place , can you please help me append it to fulfill above 2 points .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 04:42 AM
If you're not already taking this approach, it sounds like you want to keep the Business Rule w/o a script before Insert, then create another one before Update with the Filter Conditions Account changes to handle these 2 scenarios. Your script on this BR would look more like this:
var usr1 = 'sys_id 1st user';
var usr2 = 'sys_id 2nd user';
var wlArr = current.watch_list.toString().split(',');
//add 2 Contacts to WL if Account changes to X
if (current.account == 'dc5dd0843bc02300bfe04d72f3efc41e') { //sys_id of account X
wlArr.push(usr1);
wlArr.push(usr2);
var arrayUtil = new ArrayUtil();
var finalArray = arrayUtil.unique(wlArr);
current.watch_list = finalArray.join(',');
}
//remove 2 Contacts from WL if Account changes from X
if (previous.account == 'dc5dd0843bc02300bfe04d72f3efc41e') { //sys_id of account X
wlArr.splice(wlArr.findIndex(usr1), 1);
wlArr.splice(wlArr.findIndex(usr2), 1);
current.watch_list = wlArr.join(',');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 04:42 AM
If you're not already taking this approach, it sounds like you want to keep the Business Rule w/o a script before Insert, then create another one before Update with the Filter Conditions Account changes to handle these 2 scenarios. Your script on this BR would look more like this:
var usr1 = 'sys_id 1st user';
var usr2 = 'sys_id 2nd user';
var wlArr = current.watch_list.toString().split(',');
//add 2 Contacts to WL if Account changes to X
if (current.account == 'dc5dd0843bc02300bfe04d72f3efc41e') { //sys_id of account X
wlArr.push(usr1);
wlArr.push(usr2);
var arrayUtil = new ArrayUtil();
var finalArray = arrayUtil.unique(wlArr);
current.watch_list = finalArray.join(',');
}
//remove 2 Contacts from WL if Account changes from X
if (previous.account == 'dc5dd0843bc02300bfe04d72f3efc41e') { //sys_id of account X
wlArr.splice(wlArr.findIndex(usr1), 1);
wlArr.splice(wlArr.findIndex(usr2), 1);
current.watch_list = wlArr.join(',');
}