Hello Everyone. Please can someone help me to write a client script for a sales invoice doctype that selects different warehouse automatically when brand changes. This is what i have but it’s not working.
frappe.ui.form.on(“Sales Order”, { refresh(frm) { // your code here } });
frappe.ui.form.on(“Sales Order Item”, { brand: function(frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.brand === ‘Green’) { frappe.model.set_value(cdt, cdn, “warehouse”, “Green Warehouse”); } else if (child.brand === ‘Red’) { frappe.model.set_value(cdt, cdn, “warehouse”, “Red Warehouse”); } } });
I don’t know why, but i notice that it doesn’t work with the ERPNext brand field , so i have to create my own brand field and call the value using item_code.brand. And started working… Thank you
It’s the same code…i just created my own brand field instead of using the one created in ERPNext…Then the brand field i created can now be called using item_code.brand