In Purchase Order Doctype js file, i want to add a button “Action” with Dropdown say “A” & “B”, since directly changing the core files is bad practice, i want to do it through Hooks
i did below steps but failed
created a file “purchase_order_custom.js”, and stored in custom_app–>public–>js–>purchase_order_custom.js (see below image to exactly find where i created the file)
in the file tried two codes just to see does this code even get hit or not (not added exact functionality b/z first i wanted to see does this work or not)
a)
frappe.ui.form.on('Purchase Order', {
supplier: function(frm) {
frappe.msgprint("Supplier has been selected!");
}
});
@avc I see your point, but he does not want to change any code in the erpnext app because that causes many problems when trying to update to new versions.
It will extend the behaviour. Your original js file will be executed and new js also. Sometimes you have to observe whether original js is executing or new one. This is because same event may trigger same kind of logic or code. But if you want to make js code part of logic layer, you should create file under public/js and use doctype_js hook