I would like my employees to have access to update their own profiles but only Read access on other employees’ profiles.
First, I remove the “User permission” so that employee A can see the Employee list with all other employees.
Now, if I go to Roles Permission Manager > Doctype: Employee > Enable Employee Write access, they are able to make changes to their own profile as well as other people’s profiles.
Question 1: How can I enable Write access to their own profile but only Read access to other’s?
I also want to hide sensitive information that Employee A cannot see from Employee B, but can see their own sensitive information - like address or phone number.
I can customize the fields in the Employee page and adjust the perm levels but an employee-level user will not be able to see those fields on their OWN page.
Question 2: How can an employee see all fields in their own profile but hide sensitive information in other employee’s profiles?
To not Allow employee to modify Other employees details You Can use has_permission like below
Write This in Your App Hook File
has_permission = {
"Employee": "path of your file"
}
And Below is A Function For Reference
def employee_has_permission(doc, user, permission_type):
if permission_type == "read":
return True # See all employees
if permission_type == "write":
# Write only if it's their own profile
current_employee = frappe.db.get_value("Employee", {"user_id": user}, "name")
return doc.name == current_employee
return False
And For Hidiing Sensitive Fields, you can use Client Script