Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add an eventListener to a wrapper object in Catalog Client Scripts - Type: onLoad

Teo Gamarra
Tera Expert

Please don't use AI since it provides outdated methods.

 

Hello folks! how can I add an eventListener to a wrapper object (see screenshot) in Catalog Client Scripts - Type: onLoad. 

 

Currently I'm using a setInterval to grab the value of an element within the wrapper object, however I want to do it with a listener since the setInterval is time-based and not event-driven (onKeyup, input)

 

function onLoad() {
setInterval(function () {
var wrap = g_form.getControl('short_description');
g_form.showFieldMsg('short_description', 'Current length is:' + wrap.value.length + '. Max length 10 characters', 'error');
}, 1000);

 

 

This works fine but as I mentioned this is time-based and also noticed that I have to click away from the input in order to visualize the length, even though the JS console value is syncing correctly 

 

image (1).png

0 REPLIES 0