- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 04:30 AM - edited ‎08-13-2024 04:51 AM
Hi folks,
I had a requirement to add users to watchlist when priority is High/Critical I created br to get members from group and its working fine. But issue is when priority of same incident changes to low again the members are not removed from the watchlist. So they are still notified. Attaching br please help me how to remove users when priority is not high/critical @Ankur Bawiskar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 05:30 AM
Try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 05:09 AM
This is the BR for adding users. What have you created to remove them? A business rule does exactly what you say it should do and when. It's not automatically reversed if the conditions aren't met anymore.
So you need a new BR or flow with conditions that it changes from high to low (or whatever requirements you have) and remove the members from the watchlist. The question is: are there any other people on the watchlist, or is it just the group? If it's just the group, you can just set watchlist to empty. If others could be in there, you will just need to remove them from the watchlist, so the others remain.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 05:14 AM
When priority will be low/moderate watchlist will be empty can u check and modify my code for that it would be great help thanks @Mark Manders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 05:27 AM
I don't believe your the adjustment to your script is a good thing to do. I added the 'else, empty watchlist' below, but really look at your process. Do you never, on no ticket have anyone on the watchlist, except on P1/P2?
Because your script runs on every Priority change (I think) and will empty it also if it goes from 3 to 4. You really should consider making it 2 rules, one adding the groupmembers, and the other one removing them.
(function executeRule(current, previous /*null when async*/) {
var members=[];
if(current.priority ==1 || current.priority==2){
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group.name','Incident Notification Alert - P1 Group Members'); //put your group name here
gr.addQuery('user.active',true);
gr.query();
while(gr.next()){
members.push(gr.getValue('user'));
}
var new_memb='';
if(current.watch_list.toString().length>0){
new_memb=current.watch_list.toString()+','+members.join();
}else{
new_memb=members.join();
}
current.watch_list=new ArrayUtil().unique(new_memb.split(',')).join();
}else{
current.watch_list='';
}
})(current, previous);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 06:01 AM
Your solution not working @Mark Manders please let me know changes in same br if u can
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 06:17 AM
What is isn't working? I just ran it on my PDI and it was emptying the watchlist when priority changed to anything but 1 and 2. The rest I took from your script which was working according to your question.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark