Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Hide a field in a catalog item view based on requestor's user role

GamNOW
Tera Contributor

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)

GamNOW_0-1760134289242.png

 

10 REPLIES 10

SanjivMeher
Mega Patron
Mega Patron

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.

Rafael Batistot
Kilo Patron

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.

 

https://youtu.be/_FB5FBdYcmY

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

RaghavSh
Mega Patron

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.


Raghav
MVP 2023
LinkedIn

@GamNOW Did this answer?


Raghav
MVP 2023
LinkedIn