Hide Catalogue Variables Based on Role

Dan Tolgyesi1
Tera Expert

Hi,

I was just wondering if there is a way to hide catalogue variables based on role.

On most catalogue items, I have a field where the user must select a amanger to approve the request. However if the user has the "approver" role. They do not need to do this.

Is anyone able to advise on this. I have tried using a UI policy where you select the caller.id.role = approver but this is still not working.

Any Ideas?

Thanks
Dan

5 REPLIES 5

Wendy Peterson
Giga Guru

I would do it with a Client Script. It wouldn't be exactly this but this is what i have for a couple of mine. And do it by Role.

function onLoad() {
var notListed = g_form.getValue('variables.rfa_requested_for_v');

if (role == 'approver'){
//hide requested for and request type
g_form.setDisplay('variables.rfa_requested_for_v', false);
g_form.setDisplay('variables.rfa_access_type_v', false);

}
else{
//hide all new resource fields
g_form.setDisplay('variables.rfa_new_type', false);
g_form.setDisplay('variables.rfa_new_approver', false);
g_form.setDisplay('variables.rfa_new_fname', false);
g_form.setDisplay('variables.rfa_new_lname', false);
g_form.setDisplay('variables.rfa_new_dept', false);
g_form.setDisplay('variables.rfa_new_email_label', false);
g_form.setDisplay('variables.rfa_new_email', false);
g_form.setDisplay('variables.rfa_access_type_v', false);
}}


Dan Tolgyesi1
Tera Expert

Hi Wendy,

Thank you for your help with this. I have tried applying a client script but this does not seem to be working properly for me.

I have 3 fields which I need to hide with the "Approver" role. I have used the below script but this seems to cancel all UI policies that are already in place.



function onLoad() {

//hide Approval Section if approver
if (role == 'Approver'){
g_form.setDisplay('Label_Approval', false);
g_form.setDisplay('u_approved_group', false);
g_form.setMandatory('u_approved_group', false);
g_form.setDisplay('approval_managers', false);
g_form.setMandatory('approval_managers', false);
}}


Thanks
Dan


Hello Dan,



Did you get an answer for this issue?



Thanks


try this,




function onLoad() {  


if(g_user.hasRole('approver')){


g_form.setDisplay('Label_Approval', false);  


g_form.setDisplay('u_approved_group', false);  


g_form.setMandatory('u_approved_group', false);  


g_form.setDisplay('approval_managers', false);  


g_form.setMandatory('approval_managers', false);


}