How to verify if doctype.js in hook.py is working

I’m encountering difficulties in confirming whether the doctype_js defined in my hook.py is functioning as intended or not.
I’ve added my custom JavaScript file test.js in the path public/js/test.js, and I’ve included it in the hook.py for the doctype ‘CRM Lead’

I’ve double-checked the path and file name, cleared the cache, performed migrations and build, and also verified the hooks resolution order. Despite these efforts, the changes are not appearing

image

Adding my script to the client script doctype works fine. However, when it comes to moving it to production, there might be delays. Here are the versions of my current apps:
image

How can I debug this? Any insights on where I should check would be greatly appreciated.

One more thing to note is that this issue isn’t specific to just the CRM Lead doctype; it applies to all doctypes. I only mentioned CRM Lead as an example.

Hi @gopikrishnan
Please check in the inspect console in CRM lead doctype
Thank You!

Here’s what I’ve observed: Upon checking, I found that only the code I wrote in the client script doctype is appearing. Additionally, there are no errors in the console.

Is there anything else I should check elsewhere?

Hi @gopikrishnan
Please try this code. I hope it will help you

Hooks

doctype_js = {
		"Lead" : "public/js/test.js"
	}

JS

frappe.ui.form.on("Doctype Name",{
	refresh:function(frm){
		frappe.msgprint("Working")
	}
});

Thank You!

@Mohammadali is not working, do any additional steps need to be taken?

@gopikrishnan you need to migrate the system and reload from website.

@bahaou Yeah, I’ve migrated it, but there’s still no result.

@Mohammadali @bahaou Thanks for your time! Finally, I found the issue. Actually, I was in production mode. After updating the hook file, I ran migration every time, but it didn’t seem to take effect. After some time, I had a spark of insight: let’s restart the bench and try it once more.

Before that, I assumed in common_site_config.json where restart_supervisor_on_update is set to true, so I assumed that migrating the system would restart the supervisor. However, I realized that this setting doesn’t actually restart the supervisor. Consequently, even after migration, the Python script didn’t reload, and the code remained the same as before.

I believe this was the problem. After restarting the bench, everything is working fine now. I’ve checked the flow twice, and it seems to work like this. Please correct me if I’m wrong.