- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 11:40 PM
Hi All,
We have a 'Incident cancellation' widget which we need to hide if Logged in user is in the Incident watchlist. Please suggest the code snippet for the same.
Thanks
Aki
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 12:40 AM
Hi,
On server side script, you would need to check if logged in user is in watch list or not.
If you have incident gliderecord object on server then use below,
var watchListUsers=glideRecordObject.watch_list;
if(watchListUsers.indexOf(gs.getUserID()) > -1){
data.userExist=true;
}else{
data.userExist=false;
}
On HTML section of the widget, in the first tag, you would need to include below condition.
<div ng-if="!data.userExist">
</div>
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 12:00 AM
Hi,
something like this
var watchListArr = ['userA','userB']; // this will hold the sysId of the users
if(watchListArr.indexOf(gs.getUserID()) > -1){
// present
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 12:40 AM
Hi,
On server side script, you would need to check if logged in user is in watch list or not.
If you have incident gliderecord object on server then use below,
var watchListUsers=glideRecordObject.watch_list;
if(watchListUsers.indexOf(gs.getUserID()) > -1){
data.userExist=true;
}else{
data.userExist=false;
}
On HTML section of the widget, in the first tag, you would need to include below condition.
<div ng-if="!data.userExist">
</div>
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 10:26 PM
Thanks, Abhijit.