- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:04 PM
Hi Community,
I created a Script include which returns if the user has exactly the given role.
Calling this script include from List Control Omit Condition but it's not working while refershing the Release List.
Thanks,
Ankita
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 04:02 AM
Hi,
You are using the wrong method and wrong lines; I correct them
1) it should be getRoles()
2) it should be split(',')
var au = new ArrayUtil();
var roles = gs.getSession().getRoles() + '';
var roleArray = roles.split(",");
var isRolePresent = au.contains(roleArray, role);
return isRolePresent;
In the Omit new condition script remember to initialize answer as false
line 5 should be
var answer = false;
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-08-2022 10:11 PM
Omit new condition should be something like this
if(gs.hasRole('itil')){ answer = true; }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:15 PM
Hi Ankita,
The return statement should be false because you are asking the system to omit a new button. So try this,
YOu can infuse your script include instead of gs.hasRole but both perform the same thing.
var OmitNewButton = true; // omit button for all users
if(gs.hasRole('scrum_product_owner')){
OmitNewButton = false; // show button for scrum owner
}
answer = OmitNewButton;
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:15 PM
Hi Ankita,
May i know why your calling script include ??
You can use the gs.hasRole or gs.hasRoleExactly method in UI Action
Example
If (gs.hasRole('scrum_product_owner'){
answer = true
}
Or
If (gs.hasRoleExactly('scrum_product_owner'){
answer = true
}
Thanks
Chandu Telu
Please Mark ✅ Correct/helpful, if applicable,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:21 PM
Hi Chandu,
I'm calling Script include from List Control omit condition not from UI Action.
Also gs.hasRoleExactly won't work in Server Side.That's the reason of calling script include for the same purpose.
Thanks,
Ankita