ACL: Allow Incident watch list member write access to watch_list

perkinsarm
Mega Guru

We can add users to Incident Watch lists to make the incident known to them. We would like to give them the privilege to remove themselves from that watch list or add others.

Testing the condition Watch list contains javascript:gs.getUserID() doesn't work. I'm assuming this is because the watch_list is a glide list.


I have tried to write a script, but this is not working.

var arrayUtil = new ArrayUtil();

var watch_list_arr = current.watch_list.split(',');

if (watch_list_arr.length) {

  answer = arrayUtil.contains(watch_list_arr,gs.getUserID());

} else {

  answer = false;

}

On a related note, what is the best way to debug an ACL script? I've tried gs.print statements but am not finding any output.

10 REPLIES 10

cameronrichard
ServiceNow Employee
ServiceNow Employee

Hi Bradley,



Here's the script you need. Watch lists are just a comma separated String, so you can execute basic String operations on it....like indexOf:



if (current.watch_list.indexOf(gs.getUserID()) > -1)


  gs.log(true);


else


  gs.log(false);



Just replace the gs.log lines with what you need it to do.



Thanks,


Cameron


Tim Deniston
Mega Sage
Mega Sage

In the script field on the ACL, put this in:



current.watch_list.toString().indexOf(gs.getUserID()) > -1


That should do it.


perkinsarm
Mega Guru

Cameron, Tim,



Thanks for both suggestions. I would think that would work too, but for some reason this ACL doesn't seem to be firing.


There are two existing write ACLs on incident.watch_list.


One grants write access to users with the itil role.


The other is conditional where the caller is the current user or the opened by is the current user.


I added a 3rd ACL that is advanced and only has a script. It doesn't require a role or have any conditions. It doesn't seem to be firing.



Do either of you have any idea why this 3rd ACL never runs?