Skip to main content
Kinetic Community

Multiple Checkbox Option Events

A Customer has a requirement to use Multiple Checkbox Values to Insert and Remove another Question.

Usage

A good usage for this type of functionality would be on an Application Request Service Item.  For example, you have the following Checkbox list of Applications:

  • Word
  • Excel
  • Remedy
  • Crystal Reports

In this situation if the end user selects either Word or Excel you need to Insert another question to collect the MS License Key.  You also need to Remove the MS License Key question if both Word and Excel are unchecked.

 

Example

A sample Service Item has been created to show how this functionality can be used.  This Service Item is called Multiple Checkbox Option Events and has the following questions:

Application List - Checkbox containing Word, Excel, Remedy, and Crystal Reports.

MS License Key - Free Text that will be Inserted if either Word or Excel is Checked and Removed if Word and Excel are not selected.

Application List.png

If the end user selects either Word or Excel then the MS License Key question is Inserted:

Insert based on Word or Excel.png

If both Word and Excel are unchecked then the MS License Key question is Removed.

Application List.png

To accomplish this type of functionality I created 3 Events on the Application List Question:

Event 1:

Event:  click

Action:  Insert and Remove

Action Name:  Insert MS License Key - Word or Excel

Fire Event If: 

obj.checked==true && (obj.value== "Word" || obj.value== "Excel" )

Elements to Insert:

MS License Key

Event 2:

Event:  click

Action:  Insert and Remove

Action Name:  Remove MS License Key - Word

Fire Event If:

(obj.checked==false && obj.value== "Word") && ((KD.utils.Action.getQuestionValue("Application List").indexOf("Excel"))==-1)

Elements to Remove:

MS License Key

Event 3:

Event:  click

Action:  Insert and Remove

Action Name:  Remove MS License Key - Excel

Fire Event If:

(obj.checked==false && obj.value== "Excel") && ((KD.utils.Action.getQuestionValue("Application List").indexOf("Word"))==-1)

Elements to Remove:

MS License Key

Please note that Events 2 and 3 are using the Javascript .indexOf() Method.  Below is a definition of this Method:

The indexOf() method returns the position of the first occurrence of a specified value in a string.

This method returns -1 if the value to search for never occurs.

For more information about this Method please see the following site:

http://www.w3schools.com/jsref/jsref_indexof.asp

The indexOf() Method is searching the Application List question for the position of Excel or Word.  If Excel or Word is not found within the Question it will return a -1 value.  Therefore if the Word option is Unchecked and Excel does not appear in the Application List question then we are Removing the MS License Key question.