Make some fields Read only depends on session users

Hello Everyone

I have an HR login and employee login. I would like to make some sessions read-only while login with employees and as well as make some sessions write also.

I tried so many ways.

“eval: code” on employee master, under some fields read-only depends like,
"eval:frappe.session.user==“Employee”

& script on employee master
onload(frm){
if(frappe.session.user==“Employee”)
{
cur_frm.set_df_property(“employee_status”, “read_only”,1);
}
}

But nothing works please help me with this.

@jinsy cur_frm.set_df_property(“employee_status”, “read_only”,1); should work just fine .
try this: open the page of an employee . right click anywhere , inspect elements , click console . and write it there and see if the elements is disabled .

The script you’ve got works fine for me. More broadly, though, managing read/write permissions via client side scripting is inherently insecure. Is there a reason you’re trying to do it this way rather than with the (far more secure) role permission system?