The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Uncaught TypeError: Cannot read property 'style' of null

xiaix
Tera Guru

find_real_file.png

 

find_real_file.png

 

I'm looking at an RITM.

On this RITM, I have a Macro variable (pointing to a SP Widget) that seems to be causing this issue.  If I make this macro variable active = false, this RITM loads fine.

 

Since the error is on ServiceNow's code side, I suppose there's no fix for this... however, it leaves one to beg the question, why do the individuals that code ServiceNow itself never do any try/catch or "if element exists" code???

Bad coding practice (ServiceNow default):

ge.getElementParentNode().style.display = "none"

Good coding practice:

if (ge.getElementParentNode())
     ge.getElementParentNode().style.display = "none"

 

The problem is, because of this error, the entire page breaks and any UI Policy, Client Script, ... anything that uses JavaScript fails.

1 ACCEPTED SOLUTION

rajesh9885
Mega Guru

Found the same issue with Kingston and was given this workaround and it worked for us

 

The workaround can also be found using the following URL:
KB0691852 - Request Item and Service catalog task forms are broken after upgrading Kingston Patch 6

 

regards

View solution in original post

6 REPLIES 6

Dhravesh Murpan
Mega Expert

I faced the same issue, this happens when ever you are trying to show/hide the variable which is Macro.
something like g_form.setDisplay('macro_name',false);

as Alternative I am using the DOM manipulation by adding the DIV ID on the macro and using below

var x = document.getElementById('DIV ID');
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";

Wish that were true.

I'm getting this now on a checkbox variable.  If I make this "Active = false", I no longer have the issue.

 

find_real_file.png

 

find_real_file.png

 

 

find_real_file.png

 

rajesh9885
Mega Guru

Found the same issue with Kingston and was given this workaround and it worked for us

 

The workaround can also be found using the following URL:
KB0691852 - Request Item and Service catalog task forms are broken after upgrading Kingston Patch 6

 

regards

Yep, that workaround solved it for us as well.  Thanks!