Hello
I’m trying to move as much as possible of a Form Script from the WUI Script window into a script file and then execute it with frappe.require().
Using the User doctype, it’s working as expected.
Here’s the script.js file
console.log(frappe);
frappe.ui.form.on('User', {
refresh: function(frm) {
console.log("refresh:");
},
validate: function(frm) {
console.log("validate:");
console.log(frm);
}
})
I then call this file in the WUI Form Script window with this
frappe.require(["assets/script.js"]);
The initial refresh is triggered when the form loads along with any subsequent validation events
However for the initial refresh event on a Custom doctype it does not trigger, only the subsequent validation and refresh after clicking the Save button.
Why is this the case? And more importantly, is using frappe.require the correct way of moving all the Form script logic to a file?