Hi all,
I have built a custom app with a new doctype named ‘Patient’.
I want to be able to create an address directly from that patient and to linke the address automatically at the creation, the same way it is linked to a customer or lead for example:
Example: Client address creation
At the creation, the reference link is automatically created:
When trying to do it in the custom app, the reference links are not populated.
It seems the dynamic link doesn’t work.
Here is my code:
frappe.provide("customApp");
customApp.PatientController = frappe.ui.form.Controller.extend({
refresh: function() {
var me = this;
frappe.dynamic_link = {doc: me.frm.doc, fieldname: 'name', doctype: 'Patient'};
if(me.frm.doc.__islocal){
hide_field(['address_html']);
frappe.geo.clear_address_and_contact(me.frm);
}
else {
unhide_field(['address_html']);
frappe.geo.render_address_and_contact(me.frm);
erpnext.utils.set_party_dashboard_indicators(me.frm);
}
}
});
$.extend(this.frm.cscript, new customApp.PatientController({frm: this.frm}));
Since I have also a mapping with a customer, I tried to add the following dynamic link but it is not working either:
frappe.dynamic_link = {doc: me.frm.doc, fieldname: ‘customer’, doctype: ‘Customer’};
If anyone has any clue on how this could work and if I am missing something in the way the data is passed to the address, that would be great.
Thank you!