Redirect to list after Submit

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”);
}
});

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?

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?

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?

Yes i’ve noticed too, Unfortunately submit works after refreshing page.