Hide a variable on record producer based on role of logged in user

rambo1
Tera Guru

Hi I have a field on record producer which is in customer service scope.

that field should only visible to user with role ' sn_customerservice.customer_admin'.

How do I achieve this?

7 REPLIES 7

Alex150
Mega Sage

Hi,

Use Catalog Client Script for it

function onLoad() {
    if(!g_user.hasRole('sn_customerservice.customer_admin')){
        g_form.setVisible("field", false);
    }
}

 

somehow this is not working, it is giving access to everyone

I tested it on my dev instance and it works

find_real_file.png

Please pay attention on UI type and the third Script line. In my case this field was Mandatory.

If you use Service Portal and it doesn't work I need to investigate it additionally.

find_real_file.png

Pooja Mallikarj
Kilo Sage

Hi,

You can do this either by catalog UI policy /Catalog client script

You need to write below script if you are using catalog UI policy

function onCondition() {
if(g_user.hasRole('sn_customerservice.customer_admin'))
{
g_form.setDisplay('u_field',true);

}

}

Note: Make sure Reverse if False check box is true.

Thanks,

Pooja M