|KURL||Character Count On a Search Button.rb|
Some common functionality used within Kinetic Request is to allow an end user to enter a name into a Search Name question and then to press a button to return that person's information from another Remedy form. This functionality works great, until it is released to the general population where they enter a "W" into the Search Name question and press the button. The button contains a Click Event and does a Set Fields External Action. By only entering a "W" the end user has just searched your User or CTM People form for all Names that begins with a "W". So if you have a large environment you could be returning all of the Williams, Wrights, ..., and Wilsons. This could be BAD BAD BAD as now your end user is reporting a poor response time. So how do we "fix" this issue?
To correct this issue we will need to add to the Click Event that runs the Set Fields External Action. The addition will be made to the Fire Event If. See below:
KD.utils.Action.getQuestionValue("Search Name").length > 2
The length property returns the length of a string (in characters).
By adding the .length code to the Fire Event If we ensure that the end user enters at least 3 characters into the Search Name question. That seems great but now how do we tell the end user that they need to enter at least 3 characters before they can click the button? I would suggest that you add another Click Event on your button. See below:
Event Name: Alert Error Message
Fire Event If: KD.utils.Action.getQuestionValue("Search Name").length < 3
Custom Code: alert('You must enter at least 3 characters into the Search Name Field');
As seeing this type of functionality in action always helps I have attached a Service Item called Character Count on a Search Button to this posting.