Try ERPNext Buy Support Partners Foundation

Filter with LIKE in frappe.client.get_list

Have done query directly on database and works as desired, but getting errors on script relating to formatting filters.

Here is section of code as tried:

frappe.call({
  method: 'frappe.client.get_list',
  args: {
  	doctype: 'Payment Entry', 
           	filters: {
           		[“reference_date”, “LIKE”, curYearstr],
           		'party_name': frm.doc.party_name,
           		'docstatus': 1
           		},
  	fields: [ 'SUM(paid_amount) AS totalPaid', 'SUM(total_allocated_amount) AS totalAllocated' ],
  		as_list: true,
  		limit: 1,
  		async: false
  	  },
  	  callback: function (data) {...

Have also tried “reference_date”: [“LIKE”, curYearstr ],

Suggestions appreciated.

ERPNext: v12.12.1 (version-12)
Frappe Framework: v12.10.2 (version-12)

The way you’re trying to create the filters object should throw SyntaxError . Try something like

frappe.call({
    method: 'frappe.client.get_list',
    args: {
        doctype: 'Country',
        filters: [
            ['name', 'like', '%a%'],
            ['date_format', '=', 'dd-mm-yyyy']
        ]
    },
    callback: e => console.log(e.message)
})

Thank you, worked. Key was turning

‘field_name’: value,

which is valid into

[‘field_name’, ‘=’, value],

when other filter arguments change to use [ ]