Store user's preferences

I would like to have a way to store user’s preferences (cookies? a container? in database?). For example which sections of a doctype he/she wants to be opened or closed when the doctype is loaded.
Is there sothething similar implemented or has anyone any idea on how to begin dealing with this?

3 Likes

@emakis I think there is something implemented for filters …have a look at __UserSettings table

@JoEz is right. We store user preferences like filters and list view in __UserSettings table.
You can use frappe.model.user_settings.save(doctype, key, value) to save a key-value pair specific to the user.
Then you can access it by frappe.get_user_settings(doctype, key)

1 Like
frappe.model.user_settings.save("Communication", 'Inbox', {
			last_email_account: this.current_email_account
		});
2 Likes

Hi,
My comment might not have nothing to do with this but based on this i managed to remove (manually) the filters that the User added … Maybe a limit on Filters should be added!!.

I think this should be tested on V11 and V12 to avoid errors as this filter puts CPU 100% and hangs the browser…

| Patient Appointment | {“last_view”: “List”, “Calendar”: {“last_calendar_view”: “Default”, “order_by”: “tabPatient Appointment.modified desc”, “filters”: [[“Patient Appointment”, “status”, “=”, “Open”]]}, “updated_on”: “Tue Dec 03 2019 12:26:58 GMT+0100”, “List”: {“order_by”: “tabPatient Appointment.modified desc”, “filters”: [[“Patient Appointment”, “status”, “in”, [“Open”, “Scheduled”]], [“Patient Appointment”, “physician”, “=”, “wassantha kumara”], [“Patient Appointment”, “appointment_date”, “=”, “2019-12-04”]]}, “Gantt”: {“gantt_view_mode”: “Day”, “order_by”: “tabPatient Appointment.appointment_date asc”, “filters”: [[“Patient Appointment”, “status”, “=”, “Open”]]}} |

For anyone coming here to look up how to do this, as of this commit, __UserSettings are actually DELETED every time a user views a Kanban board. This makes them a very unreliable data store, at least at the moment. See issue #17227 for details.