ACL: Allow Incident watch list member write access to watch_list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 08:20 AM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 10:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 10:30 AM
In the script field on the ACL, put this in:
current.watch_list.toString().indexOf(gs.getUserID()) > -1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 10:42 AM
That should do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 10:53 AM
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?