Why can't I use "document.getElementById" in catalog item's client script

Allen17
Tera Contributor

error log: TypeError: Cannot read property 'getElementById' of null,I didn't check the Isolate script

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Allen,

getElementById is blocked by ServiceNow since it may affect or break your functionality whenever upgrade happens or patch is applied.

but if you still want to use that then isolate script checkbox set it to false

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I have been set it false, but it still not working

Harish KM
Kilo Patron
Kilo Patron

Hi in Madrid we cant use DOM. If you want to access DOM you need to make isolate check box to true

Regards
Harish

asifnoor
Kilo Patron

Hi,

Refer to this article which suggests why you cannot use the docuemtn.getElementByID

https://hi.service-now.com/kb_view.do?sysparm_article=KB0719250