Filter Database query based on the current users

Hey guys
i need to return only records , if the owner is current (logged in) user i have following query i dont know how to use filter for current user
frappe.db.get_all(“Invoices”,filters={(“name”, “like”, “%” + cstr(term) + “%”)})]

@amirtdss , Try with this code, this returns only those invoices which are created by current loged in user -
frappe.db.get_all(“Sales Invoice”, filters={“owner”:frappe.session.user}, fields=[“name”])

3 Likes

Hello.
is it possible to make such a filter for records that are not created by the user, but assigned to him in notifications?

Привет @11113 ,

If the document has the field, you should be able to filter the records using the filters.
frappe.db.get_all("...", filters={"assigned_to":frappe.session.user}, fields=["name"])

Regards,

Ivan

Hello.
I make new file name_doctype_list.js

frappe.listview_settings[‘name_doctype’] = {
add_fields: ["_assign"],
filters:[["_assign", “like”, “%”+frappe.session.user+"%"]]
};

it is working