ERPNext Conference 2019* ERPNext.com Blog

Unable to load javascript file in custom doctype


#1

i am new to erpnext. i am making a new module for interview. But when i tried to load javascript function in .js file it is not responding. I have checked in console too but couldnot find any error why .js file not running.


#2

I have not use the .js file for my JavaScript u can use custom script
It is located in Setup > Customization > Custom Script u can Write u r JavaScript here it will work 100%
Try the following link
[https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts]


#3

Thanks for your quick reply. Actually i created a doctype called interview in the interview.js file i have to run some code to fill values from server side.
Unfortunately any code inside interview.js file is not working even i just write console.log(“checking js file”)
on load function but it didnot run.
please help me out why interview.js file not working in custom doctype.


#4

use bench frappe --build command
After modifing .js file it will work

If u have custom app change name “frappe” in the command to yourappname


#5

i have done what you suggest but same result.
I have added console.log() in apraisal doctype and it worked . But in custom doctype no result shown in console.
i will try to download new vm image and test these things there.
i am using frappe version
Installed Apps
ERPNext: v11.1.38 (master)

Frappe Framework: v11.1.35 (master)


#6

Now it is working in custom script type.
Thanks for your time.

i have another issue that is very simple.
i have made new doctype Interviewer Group and child table Interviewer Group Applicants
I want to load applicant names which have status = open

I am using following script.

cur_frm.fields_dict[“applicant”].grid.get_field(“group_applicant”).get_query = function(doc){
return {
filters:{
“status”: “Open”
}
}
}

but it is giving error .

following is my doctype image:


#7

i have checked my own mistake in script it is now working:
script i used is this:

cur_frm.fields_dict[“group_applicants”].grid.get_field(“applicant”).get_query = function(doc){
return {
filters:{
“status”: “Open”
}
}
}