Unable to get property 'on' of undefined or null reference

2530
6
Jump to solution
01-28-2019 07:40 AM
Nicole_Ueberschär
Esri Regular Contributor

After publishing the latest version of my survey (which is quite long, xls attached) I get the above error message when I try to open the survey in the web form. No error message during publishing. On Samsung Tablet it takes long (not to say forever...) to open but it opens eventually, iPhone is much quicker. 

Published with Connect 3.1.126

Edit: I already tried to recreate the survey by publishing it under a different name and a new service but it didn't help. 

I also had the brilliant idea to check the choice names and found a couple of apostrophs and blanks that I removed and deleted and published the survey again but no change. 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Nicole_Ueberschär
Esri Regular Contributor

Ok, on page 3 I narrowed it down to the relevant condition of the repeat  (Question 4.8) which is causing this error: TypeError: Unable to get property 'nodeName' of undefined or null reference.

When I take it out, the form is created, with any condition in that field it fails (it creates the form but the relevant section is not working properly. iPhone view is fine. 

Additionally it didn't seem to like a group inside a repeat (I could remove this one it wasn't really necessary). 

View solution in original post

0 Kudos
6 Replies
BrandonArmstrong
Esri Regular Contributor

Hi Nicole,

Please re-upload the XLSForm as I believe it may not have worked.

Thanks,

Brandon

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Thanks for the reminder. I had to rush out of the office and forgot to attach it. I also updated my post. 

Thanks for looking into it. 

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Another update after playing around a bit: 

After removing the last two pages I still get the error message (this time with TypeError: Unable to get property 'nodeName' of undefined or null reference)  but the 5 pages are created but relevant/required dependencies are not correct.

After adding page 6 I get my old error again: Unable to get property 'on' of undefined or null reference and the web form is not created/displayed. 

After that I started all over again by deleting the survey and starting with only one page: no problem;

with two pages: (survey has to be recreated due to changes to the gdb) no problem; 

with three pages (1-3): (survey has to be recreated due to changes to the gdb) -> nodeName error again. I checked on all groups and repeats but they all match. A survey of three pages is still created but the relevant/required dependencies are not correct as above. 

I removed page 3 and added page 4: (survey has to be recreated due to changes to the gdb) no problem;

Added page 5: fields are added to the gdb, no problem;

added page 6: new gdb needs to be created, -> Unable to get property 'on' of undefined or null reference, no webform

removed page 6 and added page 7: new gdb, no problem.

I am now elaborating on the pages 3 and 6 but couldn't identify the problem yet.

On the side comment: Why does the signature that I define in Connect not allow me to enter a signature in the web form but when I create the form on the Website it's fine? 

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Ok, on page 3 I narrowed it down to the relevant condition of the repeat  (Question 4.8) which is causing this error: TypeError: Unable to get property 'nodeName' of undefined or null reference.

When I take it out, the form is created, with any condition in that field it fails (it creates the form but the relevant section is not working properly. iPhone view is fine. 

Additionally it didn't seem to like a group inside a repeat (I could remove this one it wasn't really necessary). 

View solution in original post

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Can someone say why this relevant condition is causing an error in the webform but not in the field app? The condition is Question 4.7 >0 to show the repeat section with repeat count=4.7

0 Kudos
williamholding
New Contributor

This issue arises when js/jquery is not able to refer to the element. It is because at the time of rendering the page(view), object is null or undefined - which means that there is no instance of a class in the variable. If you are getting data for object from an async call(api's), these kind of problems will arise. So you should always check the object whether it is null or undefined then if it is not, you can access its properties.

The standard way to catch null and undefined simultaneously is this:

if (variable == null) {
// your code here.
}

Because null == undefined is true, the above code will catch both null and undefined.

Also you can write equivalent to more explicit but less concise:

if (variable === undefined variable === null) {
// your code here.
}

This should work for any variable that is either undeclared or declared and explicitly set to null or undefined.

In most cases this error is related to getElementById(). So getting a value from an input could look like this:

var value = document.getElementById("frm_new_user_request").value

Also you can use some JavaScript framework, e.g. jQuery, which simplifies operations with DOM (Document Object Model) and also hides differences between various browsers from you.

Getting a value from an input using jQuery would look like this:

input with ID "element": var value = $("#element).value
input with class "element": var value = $(".element).value

 

0 Kudos