Custom script on the doctype doesn't affect Web Form?

Hello everyone, I have been using Schools module of erpnext for University System, I’ve modified Program Enrollment doctype according to my needs and used some custom script to filter. enable/disable or set options dynamically.
Now I tried to make a web form using that doctype but the script that I added isn’t working on the web form. Is this really the way erpnext works or I’m doing something wrong?

Hi,
I believe thats the way it works, you can write script in you webform.js file to apply filters.
Thanks

Thanks for the reply.

Please, can you provide an example of adding the script in webform.js?

Sorry for my ignorance, but what the users will be interacting with is the web form, not the doctype itself then what’s the point of adding a custom script in a Doctype if it isn’t going to affect the web form?

Hi, You have to bind to events and elements. for eg:

  • to get the value in a select field project

let project = $(‘select[name=“project”]’).val();

  • to get all tasks in project use

frappe.call({
method: “frappe.client.get_list”,
args: {
doctype: “Task”,
fields: [“name”],
filters: [[“project”, “=”, project]]
},
callback: function(data){
//get the task field and update the select option of task field
}
});

It isn’t strait forward like you do on a doctype, but things can happen.
Thanks