The CreatorCon Call for Content is officially open! Get started here.

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

 

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo 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

In this video, we have demonstrated how to control the behavior of a Service Catalog using the Catalog UI Policy. Using Catalog UI Policy, you get to hide or make the field read-only or mandatory. Furthermore, to strengthen your skills and experience I recommend live instructor-led courses and ...

RaghavSh
Kilo 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