Add and modify Breadcrumb in a custom doctype

Hi. want to add Breadcrumb in a custom doctype.

I have 2 custom doctypes. Doc 1 and Doc 2.
I have a link field in Doc 1 that is connected to Doc 2.
When i click on that link field in Doc 1 it is taking to corresponding Doc 2 form. here Breadcrumb showing as App > Doc2 But i would like to see the breadcrumb as App > Doc 1 > Doc2 because Doc 2 form is opened through Doc 1.

Is it possible ? Can anybody tell how can i achieve this ??

Hi. Did you ever have any luck with this? I am wanting to get the same sort of effect getting my custom doctype to point back to the standard Support module.

After a bit of trial and error I found a solution that looks something like this:

// Assuming 2 custom doctypes name 'Doc 1' and 'Doc 2'
frappe.ui.form.on("Doc 2", {
        refresh(frm) {
                // Clear the existing breadcrumbs. Set custom breadcrumbs will not do this automatically
                frappe.breadcrumbs.clear();
				
		// Now add breadcrumb for the 'parent' document
                frappe.breadcrumbs.set_custom_breadcrumbs({
                        label: frm.doc.doc1field, //the name of the field in Doc 2 that points to Doc 1
                        route: '/app/doc-1/' + frm.doc.doc1field,
                        });

                // Finally add the breadcrumb for this document  
                frappe.breadcrumbs.set_custom_breadcrumbs({
                        label: frm.doc.name,
                        route: '/app/doc-2/' + frm.doc.name,
                        });

        },
};