
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 06:40 AM
Hello!
I have a record producer and I am trying to write a script for it that checks whether the current user has a specific role and if they do, to add th user to the watch list when the form is submitted.
Please could someone help me out with this?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 06:53 AM
Hi,
Assuming you are talking about Logged in User. Please find code below:
if(gs.hasRole('<roleName>')) {
current.watchlist = gs.getUserID();
current.update();
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 10:28 AM
Hi Ricker,
As Record will be created newly so I don't think there would be any value present in watchlist.
In case any Watchlist is also present you can use below line in that case:
current.watchlist = current.watchlist + ',' + gs.getUserID();
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023