Skip to main content
Kinetic Community

Free Text Search

Import Files
Service Item
KURL Free Text Search.rb
Use Javascript to search for Keywords in your Kinetic Survey.


A customer recently wanted to create a Follow-up Survey that would be sent once an Incident was Closed.  This is a standard use for Kinetic Survey however, they added a twist in their requirements.  The requirement was to create reports that would search a Comments question for any of the following text:

  • Good
  • Great
  • Awesome

Of course this can be done and it is "simple" for any report writer, however, the downfall is that your Report performance will take a hit.

To meet this requirement and to avoid the Report performance issue I developed another solution.  This solution has been added to the Free Text Search Survey attached to this posting.

The solution searches the Comments questions on a Before Submit action and if it finds the text of Good, Great, or Awesome it will populate another field with a Yes value.  By using this solution the Report would only need to check the Good Answer question for a Yes value.  The steps below show you how I built this solution:

  1. Added a Hidden Section and created a new question called Good Answer.  Note that the Good Answer question is a Yes/No Radio button.
  2. Created a beforeSubmit Event with an Action of Set Fields - Internal on the Page element.  The Event has the following Fire Event If:

KD.utils.Action.getQuestionValue("Comments").search(/(good|great|awesome)/i) >-1

The .seach Method is defined below:

The search() method searches for a match between a regular expression and a string.

This method returns the position of the match, or -1 if no match is found.

If this statement is found to be True the Good Answer Question is set to a Value of Yes.  Note that the Good Answer Question has a default value of No.

Please note that the Hidden Section on this Example Survey is not set to Removed.  The reason for this is to show you the question if/when you import this into your environment.  Once you test this and ensure it works the way you want/need then I would suggest you set the Hidden Section to be Removed.