Need to simulate filter in User showing only applicable records of frappe.session.user


I am currently creating a doctype that should only show records where name is equal to frappe.session.user.

I have checked on user_list.js with the listview_setting but could not find out how to do such.

Many thanks.


You will need to set the filters attribute in listview_settings. please check the user_list.js for the same.
filters: [[“fielname”, “operator”, “value”]]

Thanks, Makarand

The problem with that is the filter can be deleted by the user. The User do not show other user records to other users, unless it is a System Manager or Administrator.

You will want to use role permissions to accomplish this.

Make sure you check “Apply User Permissions” on the doctype and make sure the User Doctype is selected in “Select Document Types”.

Also, make sure “Set User Permissions” is checked for the User doctype.

1 Like

Found this useful. 2 follow up questions:

  1. Is this available for group level as well, i.e. if the records is to be available for specific group and so all users within that group is allowed to view the records.
  2. If the Doctype was “Child table” then how would the permissions be allowed to be set?
1 Like
  1. This is possible if you have the group as a Linked Field in the doctype you are trying to filter. If not, then it’s not possible without customization.
  2. You can’t do permissions on Child tables/doctypes.

Is there an example in ERPNext that I can see and learn? I can’t figure out where it could be.

User Permissions is what you’re looking for: