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

sharvil Sheth1
Kilo Guru

function onLoad() {

if(g_user.hasRoles("deputy_director") {

g_form.setMandatory("approving_deputy_director", false);

g_form.setVisible("approving_deputy_director", false);

}
else{

g_form.setMandatory("approving_deputy_director", true);

g_form.setVisible("approving_deputy_director", true);

}

}