frappe.ui.form.on("Quotation", {
onload(frm){
console.log("Called from parent!");
},
onload_post_render(frm){
console.log("Called from parent! (onload_post_render)");
console.dir(frm.fields_dict.items.wrapper);
frm.fields_dict.items.wrapper.on('change', evt => {
console.log("Called from child table wrapper!");
});
}
});
frappe.ui.form.on('Quotation Item', {
refresh(frm) {
console.log(`Called from children ${cdt} ${cdn} (refesh)`);
},
onload(frm, cdt, cdn){
console.log(`Called from children ${cdt} ${cdn}(onload)`);
}
});
Got the result :
Called from parent!
Called from parent! (onload_post_render)
Uncaught (in promise) TypeError: frm.fields_dict.items.wrapper.on is not a function
at onload_post_render (quotation__custom_js:11:39)
at _handler (script_manager.js:30:12)
at runner (script_manager.js:109:16)
at script_manager.js:127:22
The line …
console.dir(frm.fields_dict.items.wrapper);
… produced a …
div.frappe-control.form-group
Exploring that with dev tools I could find no function “on”
I wonder … do you have any explanation for why the Client Script editor page offers a menu button to “Add script for Child Table” THAT DOES NOT WORK?!?!?!
It’s incredible.
(Or does it work for everyone else, but not in my configuration?)
Using your minimalist example with Quotation I did this…
frappe.ui.form.on("Quotation", {
refresh(frm) {
console.log("Called from Quotation parent!");
});
… getting me the result …
Called from Quotation parent!
I then click on the menu button, “Add script for Child Table" and see my script augmented with a second event handler, like this …
frappe.ui.form.on("Quotation", {
refresh(frm) {
console.log("Called from Quotation parent!");
});
frappe.ui.form.on('Quotation Item', {
refresh(frm) {
// your code here
console.log("Called from child table!"); // Added by me
}
})
… which gets me the following result in the console …
Called from Quotation parent!
Are you saying you DO get a “Called from child table!” message while I do not?
@MartinHBramwell I dont get on “refresh” cuz there’s no refresh event on the child table!
On the child table, you can listen for the form_rendered when you click to open the form to edit the table, or you can watch to a change event that the “refresh” method of the table will trigger inside it’s wrapper
That’s what I find to be so careless and offensive.
It’s offered as a quick start!
Most novice users exploring how to develop a Client Script will fall for it, waste hours on it, wrack their brains on what they might be doing wrong, give up, go away and never come back.
I already have years of ERPNext experience, but left it for a few months.
Nevertheless, I also fell for it! I wasted most of a day, and your time too, trying to figure out what the hell I’ve forgotten – but, nah it’s just another ERPNext booby trap.