- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 07:43 AM
Hello Community Members,
I am fairly new to ServiceNow and am stuck at a point where I cant understand the approach that I am following is correct or not.
I am trying to display a button that redirects to different ESS page based on certain condition.
This button should only be visible to a certain group of users having role abc.
I created a UI Action with Form Button checked .
In the condition if I try to write 1==2 , the button is not visible for admin . So the hiding thing is working .
However, if I type gs.hasRole('admin123') assuming admin123 is a role that admin does not have, the button is not getting hidden.
Could anyone please help/guide on this ?
Sample code in Script
if (condition==true)
action.setRedirectURL('https://dev1234.service-now.com/incident.do?sys_id=-1&sysparm_query=active=true&sysparm_stack=incide...
else
action.setRedirectURL('/ess/main.do');
Regards
Nitin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 07:52 AM
Hi Nitin,
Admin is super user. He satisfies all the roles in the system.
This thread Server-side "hasRoleExactly" in ServiceNow has a good example on how to test hasRoleExactly at serverSide
Thanks
Srinivas
Mark this response as helpful/correct if it does so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 07:52 AM
Hi Nitin,
Admin is super user. He satisfies all the roles in the system.
This thread Server-side "hasRoleExactly" in ServiceNow has a good example on how to test hasRoleExactly at serverSide
Thanks
Srinivas
Mark this response as helpful/correct if it does so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 08:46 AM
Thanks a lot Srinivas.
I was testing this against a wrong user.
The article you shared helped.
Regards
Nitin