Restrict access to certain fields

I have reports_to field in Employees in ERPNext. If empA reports to empB. Then empB can view all data of empA. I want empB to view only certain fields of empB.

I assigned perm level to fields and gave empB role profile Project Manager. and assigned role permission to Project Manager as 1 read. But it did not work?

Also since both are employees, so how to restrict this kind of access?

yes you can do under role permisssion manager
first create a new role naming empb perm lvl-1 or any name you like
then goto customize form select that field and add perm lvl-1 to it
image
now goto role permissions manager and add permissions to that user and set the permission to lvl 1
image
with this method only the person who has the role empb can see that field

no need for client script we can handle through permissions

User account
image

admin account
image

but with this way, empB wont be able to view his own fields as well since both are employees. I just want him to not see certain fields of people who report to him.

in this case create new fields in the documents and set the permissions to lvl 1 that fields will only be accesible to empA and not to empB ( custom fields)

so whenever any employee reports to another employee, I would need custom created fields for them?

you are not specifying the whole scenireo which is resulting in misunderstanding the requirments if you want to create a field for reporting just create a new doctype and name it employee reports create a link field to user and a report field and save it also create a user role for that and set to only if create by doing this anyone can report to any ohter user wihtout each other knowing only admin can see all reports also you can restrict the list of users i hope this helps

I have an employee doctype, with a field reports_to, if empA reports to empB, then empB should be able to view certain fields of empA. but right now empB can view all fields. should i use some script that if empA reports to empB then a role profile be assigned to empB and he can only view certain fields of empA but he should be able to view all fields of himself, since both are doctype employees

do you know what is the purpose of reports to field??

assigning Team Lead

the purpose of reports to field is related with hr module its a field where you mention who is your manager and who will be accountable for your salary leave attendance promotion demotion

so can I restrict based on this?

no the usecase of this field is totally different from your requriments i already mention a solution about create a custom doctype that you can fully control as per your requriments

1 Like