Hello,
I have one problem. I have two Doctypes, A and B. Inside Doctype A i have table in which on each row i link few docnames of doctype B.
When i go to some docname of doctype B and click on Menu->Links i can see on dialog the docname of doctype A in which i linked docname of doctype B.
I would like to create inside every docname of Doctype B the table with dynamic links in which i will see the same info which i can see in Menu->Links.
How to do that? I know that everything about Menu->Links is doing by code in apps\frappe\frappe\public\js\frappe\form\linked_with.js but i really don’t know how to “copy” this info to table of dynamic links.
How this Menu->Links knows every links of Doctype B? I tried also get some information in sql database from doctype B table, but no info inside database fields …
I hope I have made it clear what I mean and please for any tips/advice.
Could someone help?
ok… found it …
if(!frm.linked_with) {
frm.linked_with = new frappe.ui.form.LinkedWith({
frm: frm
});
}
frm.linked_with.show();
Now, inside frappe-bench\apps\frappe\frappe\public\js\frappe\form\linked_with.js i would like to add the content from Links to Dynamic Link table and got the error in console:
TypeError: frappe.ui.form.LinkedWith is not a constructor at Object.callback (eval at setup (form.min.js?ver=1520612983.0:2693), <anonymous>:19:24) at Object.callback [as success_callback] (desk.min.js?ver=1520612983.0:1486) at _ (desk.min.js?ver=1520612983.0:1510) at Object.<anonymous> (desk.min.js?ver=1520612983.0:1611) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at z (jquery.min.js:4) at XMLHttpRequest.<anonymous> (jquery.min.js:4)
Code inside linked_with.js:
const linked_docs = this.frm.__linked_docs;
Object.keys(linked_docs).map(dt => {
linked_docs[dt].map(value => {
this.frm.add_child('links', {
link_doctype: dt,
link_name: value.name
});
});
});
I would like also to add that sometimes this code works, i.e. i can see the links in Dynamic Link Table, but sometime it’s just showing this error and can’t see anything … even button “Links” not works…
Could anyone help?