What i should change in hooks.py to add a client script

hi i have this simple script

frappe.ui.form.on('Sales Invoice', {
    customer: function(frm) {
        if (frm.doc.customer) {
            // Simulate setting a custom value
            var custom_balance = 1000; // Replace this with any logic or value you want
            frm.set_value('custom_party_balance', custom_balance);
            console.log("Customer selected: " + frm.doc.customer + ", custom balance set: " + custom_balance);
        }
    }
});

The script works well, and I want to integrate it into my custom Frappe app. Where should I add the JavaScript file, and what should I edit in hooks.py?

Please check the documentation.

1 Like

Thank you, I tried it before and it didn’t work, so I thought there was an issue with the implementation. Now it’s working, though I’m not sure why! :sweat_smile: