Clientside script is not working

I’m trying run a script using custom script document, but it’s not working.
When I paste the same script on browser console this work as well, yes, I cleared browser cache to test the custom script. I’m using Maintenance Visit Purpose doctype on custom script document.

frappe.ui.form.on("Maintenance Visit Purpose", {
	child_field_name: function () {
		console.log("worked");
	}
});

I put that script in an app file.js and work as well too… that seems a erpnext bug

Hi @Leonardo_Augusto,
You have to select the parent doctype to apply custom script for any child add or remove trigger.
Make sure that you have selected “Maintainance Visit” (as it is the parent of “Maintenance Visit Purpose”) and then add your custom script.

Let me know if it works once you have done that.

1 Like

How I said, the script is working on browser console and in my public/js/file.js as well. I tried on Maintenance Visit doctype in custom script document, and not worked too.

@Leonardo_Augusto can you please let me know what exactly you want your custom script to do.

Since above solution will work for standard event triggers like child_add or child_remove.