I try to custom field from form Customer to get balance data account and loyalty point balance.
I write this code in custom Client Script, but the result is still 0
Anyone can help me
frappe.ui.form.on('Customer', {
refresh: function(frm) {
// Fetch Deposit and Loyalty Points data when the form is refreshed
if (frm.doc.name) {
frappe.call({
method: 'frappe.client.get_value',
args: {
doctype: 'Customer',
filters: { name: frm.doc.name },
fieldname: ['custom_deposite_balance', 'custom_loyalty_points']
},
callback: function(response) {
if (response.message) {
const { deposit_balance, loyalty_points } = response.message;
// Display Deposit Balance
frm.set_df_property('custom_deposite_balance', 'read_only', 1);
frm.set_value('custom_deposite_balance', deposit_balance || 0);
// Display Loyalty Points
frm.set_df_property('custom_loyalty_points', 'read_only', 1);
frm.set_value('custom_loyalty_points', loyalty_points || 0);
}
}
});
}
}
});