object.addEventListener is not working service portal

Abdul Wahid
Kilo Expert

hi all,

when i use 

var s=g_form.getControl("variable_name");

s.addEventListener('keyup',functionName);

 

function functionName(){

alert('inside function')

}

it works fine in catalog item Try It. but when i go to service portal its not working.shows an error has s.addEventListener is not a function 

thanks in advance

 

 

 

 

4 REPLIES 4

Brent Sutton
Mega Sage
Hi Abdul, g_form.getControl is not supported in Service Portal. You'll need to change this part of your script

Yes brent ! can you suggest any other way to implement this 🙂

 

thanks in advance

Hi Abdul, Normally the alternative is to use hasField() but this only returns true or false. You're trying to add an event listener which won't work. I'm not aware of an alternative method for what you are trying to do. Brent

let me explain what I'm trying to do.

 

i have catalog variable which is a single line text box and i need to do calculation whenever users type something .so i created a onchange on that variable in catalog client script. user enters the value and click .then on change function calls ..i know that's how on-change works so i added addEventListener to variable using getControl . this addEventListener is works fine in catalog item (Try it ) but when i try in service portal its not working