Restrict all users under a Role to a Company

I want to restrict users in bulk to a particular company in Journal Entry doctype.

I understand how User Permission works. I can take one single user and restrict that user to only view a certain company’s data.

But, I have a bunch of users who all work on one company. Then, I have another bunch of users who work on another company.

For all these users, I have to go into User Permission one by one and restrict them to a company. If a new user is onboarded onto the system, then we have to add that user again.

I want to know how we can do this based on Role?
eg. I will have a Role Company A Accountant and all the users who have this Role will only see Company A’s data.
And when we onboard a new user, and give him/her that Role, the Company restriction is automatically implemented.

Please help me with this. I have not been able to find a solution anywhere.

1 Like

Hi! There is a huge difference between
User Permission and Role Permission.

Role Permission - applies on the doctype and Fields of the respective doctype.
User Permission - applies to documents of a particular doctype.

What you need can be built using a custom script, where Once a Role (Company A Accountant) is applied to a user , A respective entry should be created with user permission.

That’s it.