Opening document B from document A Actions menu (not from custom button

I have a similar requirement, but on Actions menu item click. Is there any reference documentation and code sample.

Continuing the discussion from Linking a document B to the document A from which it was created:

Check it script.
Perhaps, help for you.

frappe.ui.form.on('DocType A', {
    refresh: function(frm) {
        // Add custom event handler to Actions menu item
        frm.page.add_menu_item('Open DocType B', function() {
            // Replace "doctype_b" with the actual DocType B name
            frappe.set_route('Form', 'DocType B', 'New DocType B');
        });
    }
});

Thank You!

1 Like

Thanks.
Menu item is there under Actions menu generated by document transition rule of workflow.

image

Issue is where and how to right the scripts to execute on click event.

Please check its syntax.

frappe.ui.form.on('Your DocType', {
    refresh: function(frm) {
        // Add custom event handler to Actions menu item
        frm.page.add_action_item('Action Button', function() {
            // here, please set your code according to.
        });
    }
});

Thank You!