Controlling Visibility of fields based on User/Role Permissions

In continuation with a previous post, as we have two teams who works on Issue Doctype,

  • one set of people would have access to a Computer, would be able to deal with all fields
  • and another set of people would need to have visibility of only a few fields as they access system primarily from Mobile
    We got to know that editing of fields can be controlled but can visibility of fields be controlled too ?
    How can we achieve the same within the current ERPNExt system. Any inputs or thoughts would be helpful.

Permission Level should do the job of hiding fields.

https://erpnext.org/docs/user/manual/en/setting-up/articles/managing-perm-level

Only edit access is controlled, currently visibility cannot be controlled,
You can raise an issue / feature request.

Workarounds / hack :

Issue-client Custom script

frappe.ui.form.on("Issue", {
	onload: (frm) => {
		for(let field of frm.fields){
			if(field.has_input || !["Section Break", "Column Break"].indexOf(field.df.fieldtype)) {
				frm.set_df_property(field.df.fieldname, "read_only", true);
			} else {
				frm.set_df_property(field.df.fieldname, "hidden", true);
			}
		}
	}
})

What this script does is makes read only fields hidden and editable fields read-only. It skips sections and column breaks because if sections are hidden all fields under that section are hidden

2 Likes

Thanks @revant, looks like this would work for us for now. Can limit visible access to few fields and also make sure fields are not editable. And if for any field we want to give edit access then we shall remove permissions altogether.

Hi ,

I’m not quite sure I get this. Why can’t you just use field permission level for this? It has both Read and Write controls, right?

Kind regards,