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

The SN Nerd
Giga Sage
Giga Sage

Perhaps tell us the outcome you are trying to achieve and we may be able to provide a best practice way of doing it?


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

I want to get the value of the variables' variables to control the display and hiding of one of the variables in the variable set

Can you provide screenshot / code snippet?
I'm unsure what you mean by "variables' variable"


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

find_real_file.png

  • I want to use default IT Equipment's value to control the display and hiding of a field in the variable set

rswhite
Kilo Contributor

Hi Paul,

I am trying to get the add to cart function to clear out the current form when pressing so I can have users request other items without having to delete the current data.  How would this need to change in order to use something other than "getElementById"?

This is onLoad catalog client script is causing the error.

 

function onLoad() {

document.getElementById('add_to_cart_button').addEventListener("click", function(){
reloadWindow(window);


});
}

 

Thank you!

Rachel