Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web form client scripts v11 not work (console error) #6981

Open
dufani1 opened this issue Feb 24, 2019 · 1 comment
Open

Web form client scripts v11 not work (console error) #6981

dufani1 opened this issue Feb 24, 2019 · 1 comment

Comments

@dufani1
Copy link

dufani1 commented Feb 24, 2019

Hello,
I added client script as below to new standard web form v 11 as per the following link guide, but the scripts not work with me. even I reloaded page, bench build, bench migrate, new site installation and cleared cache too.

client script

// Set Field Property based on value
 frappe.web_form.on(‘business_registration_type’, (field, value) => {
     if (value == ‘Domestic’) {
         frappe.web_form.set_field_property(‘telephone_number’, ‘reqd’, 1);
     } else if (value == ‘Foreign’) {
         frappe.web_form.set_field_property(‘telephone_number’, ‘reqd’, 0);
     }
 });

Console Error

Uncaught TypeError: Cannot read property ‘fields_dict’ of undefined
at frappe.web_form.wrapper.get_field (web_form_class.js:99)
at frappe.web_form.wrapper.on (web_form_class.js:129)
at Object.frappe.init_client_script (supplier-registration-application?new=1:390)

at web_form.js:40
And this
image

Please advise

@saru2020
Copy link

I had the same issue, if you debug it one more step deep enough, you'll see that, 'this'(webform) have the 'fields_dict' as null which means you've called the listener even before the form has completed its loading.
Try to put the listener inside the callback of the 'after_load' event/listener of the webform and you'll not see this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants