- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 04:55 AM - edited 12-07-2023 04:55 AM
Hello people, I'm trying hide UI policy for particular user, but the condition which i'm using is not working.
My requirement is to show this UI action to all the users who has admin role and plus it should also display to one particular user i.e 4f3e692c871e(sys_id), I tried below condition it's working fine it shows to all the admins and to all the users who are in that in 'NOW - Records-IG' group, the problem is that is is visible to all the users who are in that group. i want to show only to this 4f3e692c871e particular user and to all users who has admin role.
Please let me know if you have any solution to solve this problem.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 05:02 AM - edited 12-07-2023 05:02 AM
You have to use below code in condition to show to particular user:
gs.getUserID()=='<sys_id of user>' along with other conditions.
If you don't want to show to group users can remove that part.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 05:30 AM
The line which you added in your ui action conditiion --gs.getUserID('4f3e692c871e')--this is not the correct condition
gs.getUserID() this method returns sys_id of the current logged in user
You just need to compare gs.getUserID() ==sys_id(the id of user whom you want show the ui action)
You can add condition as below
current.isValidRecord() && current.canDelete() && (gs.hasRole('admin') || gs.getUserID()=='4f3e692c871e')
4f3e692c871e This is sys_id of the user to which you wan to show your ui action
Mark this answer as correct and helpful if it helps
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 09:39 PM
Mark this answer as correct if it helped
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 05:30 AM
The line which you added in your ui action conditiion --gs.getUserID('4f3e692c871e')--this is not the correct condition
gs.getUserID() this method returns sys_id of the current logged in user
You just need to compare gs.getUserID() ==sys_id(the id of user whom you want show the ui action)
You can add condition as below
current.isValidRecord() && current.canDelete() && (gs.hasRole('admin') || gs.getUserID()=='4f3e692c871e')
4f3e692c871e This is sys_id of the user to which you wan to show your ui action
Mark this answer as correct and helpful if it helps
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 04:51 AM
Thank you Manjusha, that was very well explained. This worked for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 05:34 AM
With the AND condition you can write the below line in condition:
gs.getUserID() != ''62826bf03710200044e0bfc8bcbe5df1" //This is sample user sysid. put the sysid of the user you want to hide for
It checks if the current logged in user is equal to this userID. If not equal then it will give you true and show the UI Action if not equal then hide the UI action.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 04:57 AM
Thank you for your response, gotcha!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 06:03 AM
Hello @Sanket Kutwal
As per the new Community rules, You can mark multiple solution as Accept.
If you find my response as helpful, Please Mark it as Accepted.
Regards,
Samaksh