How to hide fields based on any roles?

Amit32
Giga Contributor

How can I hide fields based on role? 

For example, I have a support team for which I don't want to show all the fields but managers can able to see all the fields. please help me out

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Amit,

Best to use read ACL to hide those fields based on role.

View solution in original post

10 REPLIES 10

Murthy Ch
Giga Sage

@Amit,

Then you need to write onLoad() client script:

EX:

function onLoad() {
    //Type appropriate comment here, and begin script below

    var roleInfo = [];

    roleInfo[0] = g_user.hasRole('rolename');
if(roleInfo[0]=='true')
{
g_form.setDisplay('field_name',false);
}

Let me know if you stuck anywhere

 

Thanks

Thanks,
Murthy

Alex Pandian1
Tera Expert

it can be done in two ways.

1. onload client script to hide the fields based on role

2. creating different view and apply view rules

Community Alums
Not applicable

Hi Amit,

Best to use read ACL to hide those fields based on role.

but if we have to hide more field then it would be lengthy. for every field we have to write acl.

can we do that from business rule.

Community Alums
Not applicable

No, Business rule is for server side scripting. 

Hiding a field is controlled by Client side so you can use either UI Policy script or Client script. 

Client side code is already provided by many user but use setDisplay instead of setVisible.

function onLoad() {

if(g_user.hasRole("Mention the Manager role")) // Provide the role
{

    g_form.setDisplay("Field name",true);

}
else
{
    g_form.setDisplay("Field name",false); //
}

}