I’ve added a custom button on customer doctype to pre filter a linked doctype but seems it’s not working. Here is how I went about it:
frappe.route_options = {"customer": frm.doc.name}
frappe.set_route('List', 'FT Machine')
Is this the right way?
1 Like
NCP
October 12, 2022, 7:57am
2
Hi @redgren ,
Please check it base example.
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.ui.form.on("Price List", {
refresh: function(frm) {
let me = this;
frm.add_custom_button(__("Add / Edit Prices"), function() {
frappe.route_options = {
"price_list": frm.doc.name
};
frappe.set_route("Report", "Item Price");
}, "fa fa-money");
}
});
method: 'erpnext.stock.dashboard.item_dashboard.get_data',
template: 'item_dashboard_list'
});
erpnext.item.item_dashboard.refresh();
});
}
},
edit_prices_button: function(frm) {
frm.add_custom_button(__("Add / Edit Prices"), function() {
frappe.set_route("List", "Item Price", {"item_code": frm.doc.name});
}, __("Actions"));
},
weight_to_validate: function(frm) {
if (frm.doc.weight_per_unit && !frm.doc.weight_uom) {
frappe.msgprint({
message: __("Please mention 'Weight UOM' along with Weight."),
title: __("Note")
});
}
Hope it helps you.
Thank You!
1 Like
redgren
October 12, 2022, 10:22am
3
They look the same? But mine just isn’t working
NCP
October 12, 2022, 10:30am
4
Please share your code with the field name if possible.
tonto
October 12, 2022, 10:49am
5
Above examples stopped working for us with version 13. This worked:
frm.add_custom_button( ("Pay All Invoices"), function(){
var local_doc = frappe.model.get_new_doc('Payment Entry');
local_doc.posting_date = 'Today';
local_doc.naming_series = 'PE-';
local_doc.payment_type = 'Pay';
local_doc.party_type = 'Supplier';
local_doc.party_name = frm.doc.name;
frappe.set_route('Form',"Payment Entry",local_doc.name);
});
1 Like
redgren
October 12, 2022, 12:09pm
6
Routing to Form
is working, I’m having challenges with routing to Lists, with filters
redgren
October 12, 2022, 12:10pm
7
The code is just as similar to what I posted, it worked in v13
Did it work for you ?
I am facing same problem
1 Like
Unfortunately no, it just works some times, and some times it doesn’t. Could be related to:
if the field you’re passing is available on the filters (main), yet to be certain of this but you can test it yourself.
Pejay
April 21, 2025, 9:24am
10
Hi @NCP , How to apply route_options or filters in my case because only frappe.set_route(“Report”, “Uncleared Checks Report”) apply filter but in my route is different
frappe.route_options = {
"name": frm.doc.name
};
frappe.set_route("uncleared-checks-report", "view", "report", "Uncleared Checks Report", {"name": frm.doc.name});