How can i hide fields based on user and role?

kasirao
Kilo Contributor

In my custom table have two fields

1.Manager Name

2.Mobile phone

When ever i am Impersonate to User Kasi Rao   with Admin role   on custom table above two fields will be displayed.

My requirement is like this

When ever i am Impersonate to User   Karthik Reddy with   Custom role .I want hide two field.

Is it possible to hide fields   based on Impersonate User?

If possible please help me.

11 REPLIES 11

Aravind31
Mega Expert

HI Kataru kasi rao



Kindly Open Form > right click on header > Configure > Client script > New


Fill fields, Type > Onload


script


function onLoad() {


if(g_user.hasRole('mentionrolename')


{


g_form.setVisible('Fieldname',false);       // hide that field


or


g_form.setDisplay('Fieldname',false);       //hide field


}


}




Thanks,


Aravind




Please mark answer as Correct, helpful as appropriate.


kiruthika
Kilo Expert

Hi,


Try ACL to hide a field.


give the correct table name, field and role.


don't forget to uncheck 'Admin Overrides'


Comm_ACL.PNG


ANANTHULA NAVEE
Tera Contributor

function onLoad()


{


var role_check =   g_user.hasRole('Mention the Role Name');



if(role_check == 'admin')


{


g_form.setDisplay('Field Name', false); //Hide field


}



else if(role_check == 'Mention your Custom Role')


{


g_form.setDisplay('Field Name', true); //hide field


}


Hello Naveen


Here Manager Name field is Reference.


I have going through   g_form.getReference() with call back function but it's not working.


can you please help me.


Greg42
Mega Guru

Hi,



Just create a read ACL for those fields and you're done.




Regards



Greg