ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Controlling Visibility of fields based on User/Role Permissions

customization

#1

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.

#2

Permission Level should do the job of hiding fields.

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


#3

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


#4

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.


#5

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,