I’m writing custom HTML and JS for an ERPNext “page”.
I need to write a frappe.call() that will tell me how many “address” records are present for a given “customer”.
For example: Company A has a “primary address” and “primary contact”. However, it also has another address it prefers for
shipping. When viewing the Company A record, both addresses are shown.
Thus I need to write a frappe.call() that will return both the primary address and shipping address for Company A.
I’m currently using the frappe.client.get_list server method as follows:
–
function queryTest() {
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Customer',
fields: [
// I need a field or fields that will allow me to query the Address doctype I think??
],
filters: {
name: 'Customer Name'
}
},
callback: function(r) {
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Address',
fields: [
'address_line1',
'address_line2',
'city',
'state',
'pincode'
],
filters: {
// How do I use the field(s) from the first call to filter on the second call? Or do I?
}
}
});
}
});
}