Implementing Onchange In Report

I have a report where it displays both customer code and customer name. So when the user chooses customer code it should auto populate customer name, vise-versa. I have done a piece of code to do this onchange but it not working, Is there a way to set the customer name onchange of customer code. please help.

{
“fieldname”:“customer_code”,
“label”: __(“Customer Code”),
“fieldtype”: “Data”,
“on_change”: function(query_report) {
var customer_code = query_report.get_values().customer_code;
frappe.model.get_value(‘Customer’, {‘customer_code’: customer_code}, ‘name’,
function(d) {
var customer_name = d[‘name’]
frappe.set_route(‘query-report’, ‘Statement of Accounts’, {‘customer’: customer_name});
}
}

change
frappe.set_route(‘query-report’, ‘Statement of Accounts’, {‘customer’: customer_name});

to
frappe.query_report_filters_by_name.customer.set_input(customer_name);

refer : general_ledger.js

2 Likes

Thanks Alot. Its working fine now. Just replace the old code with new one.
query_report.filters_by_name.customer.set_input(customer_name);
replacing it with this works fine.
frappe.query_report_filters_by_name.customer.set_input(customer_name);