How to add custom script files in custom app?

I have make some custom script under fixture folder in custom app.
Like
fixtures/Purchase Receipt.js
fixtures/Purchase Order.js

But it’s not working. How can i add the custom script files with my custom application? I have seen https://github.com/frappe-apps/rigpl-erpnext . Here he didn’t add anything in hooks.py file.

So how is this custom script working?

Have you tried to bench migrate ?

Sorry, @munim

Your issue that you dont have the correct file structure… Assume that you app in called “MYAPP”

myapp/myapp/fixtures/custom_scripts/

You are missing the custom_scripts folder.
Also after any change you need to run bench migrate

47

Hi munim

edit hooks.py of your app

   doctype_js = {
        "Purchase Receipt": "custom_scripts/purchase_receipts_custom.js",
        "Purchase Order": "custom_scripts/purchase_order_custom.js"
    }

If not edit hooks.py

You must copy these scripts into custom script page

/desk#List/Custom Script/List

1 Like

Thanks, after giving bench migrate, it’s working now.

Finally i have done

  1. In hooks.py i have added
    doctype_js = {
    “Purchase Receipt” : “custom_scripts/Purchase Receipt.js”,
    }
  2. I have made the file path myapp/myapp/fixtures/custom_scripts/ Assume that my app in called “MYAPP”
  3. At last bench migrate.

Thanks @kickapoo and @vinhnguyent090

1 Like

@munim I just want note (and for others that will check this setup), It is not necessary to have anything to hooks.py if you use the correct path “myapp/myapp/fixtures/custom_scripts/.js”

1 Like

even i used it it didn’t take any effect means it is not working for me.