I’m having error when trying to filter based on year as codes below:
frappe.call({
method: 'frappe.client.get_list',
args: {
'parent': 'Expense Claim',
'doctype': 'Expense Claim Detail',
'filters': [
['expense_type','in',['Medical','Additional Medical']],
['owner','=',frm.doc.owner],
['year(expense_year)','=',frappe.datetime.str_to_obj(frm.doc.posting_date).getFullYear()],
],
'fields':['expense_type','amount'],
},
callback: function(r) {
console.log(r);
}
});
This just gives me error as image below:
May I know what is the correct way to filter based on year on particular field?
NCP
February 7, 2024, 9:26am
2
Hi @muhdazwa ,
Please check the references.
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Item Attribute Value",
filters: [
["parent","=", d.attribute]
],
fields: ["attribute_value"],
limit_page_length: 0,
parent: "Item Attribute",
order_by: "idx"
}
}).then((r) => {
Another reference:
muhdazwa:
'filters': [
['expense_type','in',['Medical','Additional Medical']],
['owner','=',frm.doc.owner],
['year(expense_year)','=',frappe.datetime.str_to_obj(frm.doc.posting_date).getFullYear()],
],
args: {
doctype: "Supplier",
order_by: "name",
fields: ["name"],
filters: [["Supplier", "supplier_group", "=", args.supplier_group]]
},
I hope this helps.
Thank You!
Hi @NCP ,
Actually I’m trying to use sql function to extract year from field expense_date which is a full date but it seems Frappe doesn’t like sql function usage in the filters.
NCP
February 8, 2024, 5:20am
4
Client side, maybe it’s not possible but server side it’s possible.
Please check it: Database API
Please read the whole documentation.
I hope this helps.
Thank You!