Frappe Cloud Support Partners Foundation

Custom javascript inside custom app linked via hooks doctype_js not working

There is a custom doctype called “document” this is to attach some documents against the project. Here we have to write a custom js script to disable the attachment Remove button and Attach button based on document submission.

The below code is in Here Document is the custom doctype, which doesn’t work on document form. I have migrated the site and all. but still no luck.

doctype_js = {"Project" : "public/js/project.js", "Document": "public/js/document.js"}

Inside document.js

frappe.ui.form.on('Document', {

  before_submit(frm, cdt, cdn) {

    if (!frm.attachments.get_attachments().length) {

      //frappe.throw('You should have atleast one document in attachments');

      frappe.msgprint('You should have atleast one document in attachments!')

      frappe.validated = false

      return false;



  before_load(frm) {
      console.log('from code')
      console.log('from document page')
  refresh(frm) {

    if ($('li.attachment-row > a').has('.close') && frm.doc.docstatus === 1) {

      console.log('has close button')


      $('li > a.add-attachment').remove()




Please help.

1 Like

Add data in your build.json and then build your app by bench build --app appname
Then add js file in with this path: /assets/js/name given in build.json


Thanks, But why it doesn’t work with doctype_js?

it just works by adding

app_include_js = ["/assets/site_management/js/document.js"]

no need to have build.json file.

@Satish_Acharya frappe.validated only works inside the validate event!

Probably it’s running, but due the fact that it’s not locking the screen, the server request is refreshing the screen, before you see the message!

Dear how are you, i am looking for help in erpnext sale invoice integration with my local desktop application using API. I want to share my erpnext invoice with my local desktop application through API.
Actually i know that webhook can send invoice to my other server but as per my information that webhook can’t save response of API.

I am new with erpnext …waiting for your kind response plz.