Getting Error in Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 05:20 PM
I have a code am working on where i want users with a specific role should be able to view the records in the query below. it seems to be working but its throwing the error in the screen shot.
Here is the code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 05:34 PM
Hi @Michael48 the hasRole() method will always return true for admins, you can use hasRoleExacty() and also check your state values is it "draft" or "Draft" ?
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 08:38 PM
when i try to use hasRoleExactly it throws error on the widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 08:39 PM
I also tried to us sec admin as the role yet it allows people to see all

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 05:35 PM
Hi @Michael48 you forgot to add () after gs.getUser.
gs.getUser().hasRole("x_verw2_ac_factory.super_user") // add ()
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 08:57 PM - edited 01-08-2024 08:58 PM
are you saying you want to check if requester_delegate user has that role or u_requested_by has that role?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader