onChange Event Scripting Best Practice?

ctsmith
Mega Sage

I haven't really figured out how to do this with SN's client scripts.  Is there as way to create an onChange event script?  Think... character counter or cc number field that displays a changing info message based on character changes as a user types instead of waiting until the user focuses away from the field.  Is there a best way to do this with a client script?

Thanks!

7 REPLIES 7

AshishKM
Kilo Patron
Kilo Patron

Hi, Yes you can write onChange on any field ( column ) of form. 

If you want something asynchronous way then use the GlideAjax method to process the input value and get the desire result. 

Check this link for GlideAjax

https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f96196e

 

Thanks,

Ashish

Please mark correct answer and helpful for other if it helps you


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

I mean, before you leave focus of the field.  Event listener kind of thing.  GlideAjax will run onLoad or onChange after the field changes and the user clicks out of the field but not each time a character is entered.

Sushma R1
Tera Expert
Oh this is bit tricky You can though do it in a widget in service portal that's a easy peesy.. not sure how if it's in a catalog item variable etc

Yeah, that's catch.  Think incident form in workspace where it warns you of character count until N number of minimum characters are reached.  I know of the property you can set to show remaining characters in description field, but that's total out of 4000.  I want to show the message until the minimum 30 characters are reached.