addEventListener not working in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 11:21 AM
Hi everyone,
I'm working with a catalog item and trying to perform a calculation whenever a user types into a single-line text box variable. Here's what I did:
var s = g_form.getControl("variable_name");
s.addEventListener('keyup', functionName);
function functionName() {
alert('inside function');
}
This works perfectly in the Catalog Item (Try It) view.
However, when I try the same in the Service Portal, it throws an error:
TypeError: s.addEventListener is not a function.
I understand that onChange only triggers when the field loses focus or when the user clicks elsewhere, which is why I used addEventListener to detect keystrokes directly.
Does anyone know why this approach works in the regular catalog view but not in the Service Portal? Or is there a recommended way to handle keyup or live input tracking in the Service Portal?
Thanks in advance for your help!