ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Party name script

customization

#1

this script not work with supplier party

cur_frm.add_fetch(“party”,“customer_name”,“party_name”);

frappe.ui.form.on(‘Journal Entry Account’, {
party: function(frm, cdt, cdn) {
var child = locals[cdt][cdn];
if(!child.party) return;

	field_map = {"Supplier": "supplier_name", "Customer": "customer_name", "Employee": "employee_name", "Member": "member_name"};

	frm.call({
		method: "frappe.client.get_value",
		args: {
			doctype: child.party_type,
			fieldname: field_map[child.party_type],
			filters: { name: child.party },
		},
		callback: function(r, rt) {
			if(r.message) {
				frappe.model.set_value(cdt, cdn, "party_name", r.message[field_map[child.party_type]]);
			}
		}
	});

}

})
this message is Appear

Wrong fieldname customer_name in add_fetch configuration of custom script


Script of party name
#2

Is there any help?


#3

// cur_frm.add_fetch(“party”,“customer_name”,“party_name”);

frappe.ui.form.on(‘Journal Entry Account’, {
party: function(frm, cdt, cdn) {
var child = locals[cdt][cdn];
if(!child.party) return;

	field_map = {"Supplier": "supplier_name", "Customer": "customer_name", "Employee": "employee_name", "Member": "member_name"};

	frm.call({
		method: "frappe.client.get_value",
		args: {
			doctype: child.party_type,
			fieldname: field_map[child.party_type],
			filters: { name: child.party },
		},
		callback: function(r, rt) {
			if(r.message) {
				frappe.model.set_value(cdt, cdn, "party_name", r.message[field_map[child.party_type]]);
			}
		}
	});

}

})