Hide a field in a catalog item view based on requestor's user role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello Everyone,
How can you make a certain field invisible and not mandatory?
There is a UI policy set to where if urgent request is 'Yes'
Need by Date and Approving Deputy Director is mandatory and visible.
But in a catalog item view in the Service Portal, I want to make 'Approving Deputy Director' invisible and not mandatory if the person submitting the form has 'deputy_director' role. How can I achieve this? (I am using Yokohama)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
You need a client script in this case. You can check if the current user has this role using below line and then make field visible or mandatory
g_user.hasRole('deputy_director');
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
Hi @GamNOW
use g_user.hasRole(): This function is available in client-side scripts (including those in UI Policies) and is the standard way to check for a user's role in the browser/Service Portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11m ago
There is a possibility to check loggedin users roles in client script:
g_user.hasRole(“deputy_director”)
{
// write your logic for madatory and visible,
}
Please mark the answer correct/helpful accordingly.