I’d like to add javascript that runs for a specific DocType. I know I can use Client Scripts, but I’d like to be able to do it via code in my app, instead.
I tried doctype_js = {…}, in my hooks.py, but the code never runs…
I’d like to add javascript that runs for a specific DocType. I know I can use Client Scripts, but I’d like to be able to do it via code in my app, instead.
I tried doctype_js = {…}, in my hooks.py, but the code never runs…
Approach you took is correct, so you are definitely doing something wrong.
Make sure the JS file you added is accessible. You can check this in the browser console. Also, try clearing the cache both from the bench console and the browser console as that might resolve your issue.
If the problem persists, share your code snippet here so someone might be able to help you further.
I think it’s possible I am referencing the wrong directory…
What is the directory relative to?
If my file is in:
apps/my-app/my-app/my-module/my-code.js
What directory goes in doctype_js?
@oguruma You can check out this repo GitHub - resilient-tech/india-compliance: Simple, yet powerful compliance solutions for Indian businesses as a good reference for managing client scripts.