How to visible UI Action button only for the user who is member of watchlist field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 06:49 AM
I Have one UI action on the incident form and i want to visible that button only to those user who is the mentioned in the watchlist field.
Just to highlight that in watchlist field user name and email id both can be added and that email id can be of one group of servicenow that means all the members of that group should also be able to see that button

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 06:52 AM
Hello @VIKAS MISHRA
Please refer to this community link on how to add the UI action condition
The condition should be of type :
current.TABLE_NAME.WATCH_LISTFIELD_NAME.toString().indexOf(gs.getUserID()) > -1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 06:53 AM
Hi there,
In the UI Action condition add this:
current.kb_knowledge_base.WATCH_LISTFIELD_NAME.toString().indexOf(gs.getUserID()) > -1

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 07:03 AM - edited ‎02-15-2023 07:07 AM
Hi,
You can set the condition on the UI action so that it's only visible if the currently logged in user is on the list.
This should work for the part where a specific user is set in the watchlist:
!current.watch_list.nil() && (current.watch_list.toString().indexOf(gs.getUserID()) >= 0)
To solve the second part with mail-address in the watchlist, is a bit more complicated, and I can't think of a solution right now.
I'll give it some thought and get back later on that one.