To show/hide incidents to the watch list and group list people.

Poorva Bhawsar
Mega Sage

Hi Community,

 

I have a xyz checkbox, when this checkbox is checked, watch list and group list fields are mandatory. Whatever users and groups are added over there those users and groups should be able to see those incidents. For other users and groups who are not added into these fields shouldn't be able to see these incidents.

 

var user = gs.getUser();
var userIsInWatchlist = false;
answer = false;
var watchlistArray = current.watch_list.toString().split(',');

for (var i = 0; i < watchlistArray.length; i++) {
    if (user.isMemberOf(watchlistArray[i].trim())) {
        userIsInWatchlist = true;
        break;
    }
}

if ((userIsInWatchlist)) {
    answer = true;
}
 
I tried something like this but its not working.
 
Thanks
6 REPLIES 6

Rutuja Khalate
Tera Guru

Hello @Poorva Bhawsar ,

 

You can replace this line 'var user = gs.getUser();' with below

var user = gs.getUserID();

 

And this line 'if (user.isMemberOf(watchlistArray[i].trim())) {' with below

if (user.includes(watchlistArray[i].trim())) {

 


Please mark this response as correct or helpful if it assisted you with your question.

Best Regards,
Rutuja Khalate

No this is not working.

I  only want watchlist users and group list groups to view the incident records when xyz checkbox is true.

SANDEEP28
Mega Sage

@Poorva Bhawsar In Watch list you can add only user right ? not groups. Do you have separate group list field ??

Yes