Struggling to fetch primary contact link & billing address link for customer/supplier after v8 upgrade. As the structure has been changed and dynamic link table has been introduced.
Earlier used below code to fetch it:
frappe.ui.form.on('Payment Entry', 'onload', function(frm){
if(frm.doc.__islocal){
if(frm.doc.party_type == "Customer") {
frappe.call({
'method': 'frappe.client.get_value',
'args': {
'doctype': 'Contact',
'fieldname': 'name',
'filters': {
'customer': frm.doc.party,
'is_primary_contact': 1
}
},
callback: function(r){
frm.set_value('contact_person', r.message.name);
}
});
}
}
});
get_default_contact & get_default_address functions are not white listed in frappe, so unable to use them directly. Tried using them in custom app code:
@frappe.whitelist()
def set_contact_details(out, party, party_type):
out.contact_person = get_default_contact(party_type, party)
if not out.contact_person:
out.update({
"contact_person": None,
"contact_display": None,
"contact_email": None,
"contact_mobile": None,
"contact_phone": None,
"contact_designation": None,
"contact_department": None
})
else:
out.update(get_contact_details(out.contact_person))
& calling it though custom script in Payment entry, but getting error: 404 (NOT FOUND) @ frappe.call({
frappe.ui.form.on("Payment Entry", "party", function(frm){
frappe.call({
'method': 'customapp.customapp.api.set_contact_details',
'args': {
'out' : frm.doc,
'party': frm.doc.party,
'party_type': frm.doc.party_type,
},
callback: function(r){
if(r.message) {
frm.set_value(r.message);
frm.refresh();
}
}
});
});