ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Frappe.get_prev_route() not working


#1

Why frappe.get_prev_route() client-side method just work on browser console and on an app that returns null?


#2

Can you post an example of where this might be useful. I am currently trying to write a custom script that has to take values from the previous DocType and this might be useful. Were you able to get it to work?


#3

I was doing it wrong, if someone need an example how to do it, here is:

frappe.ui.form.on('DocType', {
    trigger: function (frm) {
        // Get document previous route
        prev_route = frappe.get_prev_route();
        prev_doctype = prev_route[1];
        prev_docname = prev_route[2];
        prev_doc = frappe.get_doc(prev_doctype, prev_docname);
    },
});