Here is the script
customer: function(frm) {
frappe.call({
method: "erpnext.accounts.utils.get_balance_on",
args: {date: frm.doc.posting_date, party_type: 'Customer', party: frm.doc.customer},
callback: function(r) {
frm.doc.outstanding_balance = format_currency(r.message, erpnext.get_currency(frm.doc.company));
refresh_field('outstanding_balance', 'accounts');
}
});