gel is not a function in Catalog Item OnChange in ITIL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 10:24 AM
I'm using a list collector in a catalog item. I need to check if the left bucket is empty on change, if so, enable a second field. I wrote a script that tries to get the left bucket using "gel", but when I run it in the ITIL view, it throws a JavaScript error saying "gel is not a function" and doesn't work. I unchecked "Isolate script" as well. Here's my code:
function onChange(control, oldValue, newValue, isLoading){
if(isLoading || newValue == ''){
return;
}
var left_bucket = gel('item_select_0'); // This causes the error
if(left_bucket.options.length==0){
g_form.setReadOnly('completely_remove', false);
}
else{
g_form.setReadOnly('completely_remove', true);
}
}
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 10:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 11:15 AM
I should have mentioned that originally "Isolate script" was checked and I tried to use "document.getElementById('item_select_0')" and I got a JavaScript error of "Cannot read property 'getElementById' of null", so I guess it's not recognizing my "document" reference, which is why I unchecked "Isolate script". Any other ideas? Was this fixed with a patch or something?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 10:37 AM
'gel' is simply a shortcut for 'document.getElementById', which is standard javascript.you can turn on isolate scripts and use document.getElementById
https://www.w3schools.com/jsref/met_document_getelementbyid.asp
Thanks
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 04:34 AM
Pranav, why it's not writen in documentation? And all the solusions are make from onChange or some other tolls.
Why we can't use just the javascript? Like document.getElementById.outerHtml?