How to pass field data, items from Custom Doctype to another Custom Doctype

I have 2 doctypes, When i press button i want to send fields data , and items to another doctype, during research i found sample like this. But doesn’t working at all. Any suggestion?

frappe.ui.form.on('Testdatafrom', {
    custom_button: function (frm, cdt, cdn) {
        msgprint(frm.doc.custom_label);
        frappe.set_route("Form", "Testdatato", "New Testdatato 1", { "name": frm.doc.custom_label});
    }
});

And show custom_label in here like this

frappe.ui.form.on('Testdatato', {
    onload(frm) {
        frm.set_value('custom_label', name);
    }
});

try it,

frappe.ui.form.on(‘Testdatafrom’, {
custom_button: function (frm) {
frappe.set_route(‘Form’, ‘Testdatato’, ‘New Testdatato’,{“custom_label”: frm.doc.name})
}
})

and there is no need to write below code in destination doctype

frappe.ui.form.on(‘Testdatato’, {
onload(frm) {
frm.set_value(‘custom_label’, name);
}
});

1 Like

@SanRam is right,

frappe.set_route(‘Form’, ‘Testdatato’, ‘New Testdatato’,{“custom_label”: frm.doc.name}) will work. maybe because putting “New Testdatato 1” will point to the instance “Testdatato 1” and not to the instance that you newly created.