Why can't I use "document.getElementById" in catalog item's client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2019 11:31 PM
error log: TypeError: Cannot read property 'getElementById' of null,I didn't check the Isolate script
- Labels:
-
Service Portal Development
- 4,037 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2019 11:39 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2019 11:52 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 12:24 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 01:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2021 09:23 AM
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