ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Field Read Only for some Users

Hello Community,

Is it possible to have a particular field “Read Only” for some users while editable for other users?

Any advise / help please?

Yes…it’s possible

you can use below custom script

frappe.ui.form.on(“DocType”, {
onload: (frm) => {
if(frappe.session.user === ‘user_email_id1’){
frm.set_df_property(“field_name”, “read_only”, frm.doc.__islocal ? 0 : 1);
}
}
});

1 Like

Thanks, any advise on how to change this code in case of a particular user role? so can apply it to a specific user role instead of mentioning every user.

frappe.get_roles(frappe.session.user) ===‘user_role’

1 Like

for the role check, I believe this function should use

frappe.user.has_role(“System Manager”)