Hi,
How can I redirect to List View e.g. of Purchase Orders after I click on Submit?
I achieved this on Save using the following script:
frappe.ui.form.on(“Purchase Order”, {
after_save: function(frm) {
console.log(“after_save”)
frappe.set_route(“List”, “Purchase Order”);
}
});
shahid
January 30, 2019, 3:39pm
2
use on_submit instead of after_save.
Thanks a lot Shahid. Works Perfect. What if I wanted to redirect to list for both Save and Submit within the same script?
shahid
January 31, 2019, 12:34pm
4
frappe.ui.form.on("Purchase Order", {
on_submit: function(frm) {
change_route(frm);
},
after_save: function(frm) {
change_route(frm);
}
});
var change_route = function(frm) {
frappe.set_route("List", "Purchase Order");
}
I have tried your code; I am able to redirect to List on Submit but not on Save. I see no errors on the console. What could I have missed out?
shahid
February 1, 2019, 10:32am
6
You’ve chosen Process Order in DocType Field & in Script, you’ve have DoctypeName Purchase Order.
Both should be same.
@shahid Thanks for the note. I’ve corrected as on attached screenshot. On Save it redirects to List but on Submit it doesn’t. What else could I be missing out?
shahid
February 4, 2019, 9:53am
8
Yes i’ve noticed too, Unfortunately submit works after refreshing page.