Table of Contents:
The Boolean type is used if the Answer Options of a Question represent a "Yes/No" or "True/False" choice.
That does not mean that the labels of the Answer Options have to be Yes or No. A possible label representation for a boolean state could be: "I prefer products with reduced prices". That is a boolean decision (either yes or no).
Examples of Questions that might use the Boolean Answer Option Type:
- "I am older than 18 years"
- "Energy efficiency is important for me"
Why Using a Boolean Question?
Instead of using Boolean Questions, you can of course also use an ordinary Question with e.g. the two Answer Options Yes and No and the Answer Option Type Text. However, the second answer No represents the opposite of the first answer Yes - or data-wise No is connected to the opposite product values than Yes.
That means that in this case the definition of No is redundant. Exactly for that use case the Boolean Answer Option Type can help. With the aid of that type you only have to define the Yes state and the No state is always set implicit with value set. As a result using the Boolean type can save a lot of time and simplifies your configurations.
If you look at the Example with Simple Data Binding the following value sets are defined for both states:
- Yes: all e-bikes
- No (implicit): all bike types but e-bikes
Create a Boolean Question
It is assumed that you have a Question "Do you prefer an e-bike?" with two Answer Options "Yes" and "No". This Question can perfectly be converted into a Boolean Question.
- Therefore open the Answer Option type tab in the Question properties dialog.
- Select the type "Boolean".
- The Question card appearance transforms (see image below). The Answer Options "Yes" and "No" are replaced by the option "yes". This default value can be changed afterwards to any other value like in any other Answer Option.
The only difference is that the Answer Option ID cannot be changed due to internal functional reasons for boolean Questions.
- Afterwards the "yes" Answer Option can be connected to the product values from the related product attribute. The "no" Answer Option is not visible, but implicitly set to all opposite (not connected) values.
- See Example Simple Data Binding to learn how to connect the "yes" Answer Option with values from one attribute.
- See Example with Complex Data Binding to learn how to connect the "yes" Answer Option with values from multiple attributes.
Example with Simple Data Binding
After creating the Boolean Question the "yes" option has to be connected to product attributes. In this example, the Simple Data Binding is described.
- Make sure the Question is already bound to a product attribute (in this case "Bike Type"). If you do not know how to bind an attribute to a Question, please look at the example in page Simple Mapping.
- Open the "yes" option properties dialog.
Go to the "Data Binding and Connections" tab (see image below).
Make sure that the product attribute "Bike Type" is visible below the label "Connected Product Attribute from data source:". Otherwise please return to step 1.
- Choose the attribute value "e-bike" from the selectable value from the combobox.
- After the selection the value is attached and the token "e-bike" is visible.
- You can add further values by repeating step 4 with other values.
As already mentioned earlier: All non-selected values, e.g. like "Mountain Bike" are automatically attached to the invisible "no" Answer Option. That is why it is unnecessary to implement this state in the Question card.
Example with Complex Data Binding
Furthermore the Boolean Question can also be used in combination with the Answer Option Mapping Expression. With this mapping the "yes" option can be attached to a more complex combination of different product attributes. So this can be used for example for the Question "Are there babies or small children in your household?" in a washing machine advisor.
- Make sure the Question is already created and the Data Binding Mapping is set to Expression. If you do not know how to set this mapping, please look at the example in page Expression Mapping.
- Open the "yes" option properties dialog.
- Go to the "Data Binding and Connections" tab (see image below).
- Select the attribute "child_safety_lock" and set the corresponding value to "yes". That means that the washing machine should have a child safety lock.
- Add another expression by clicking on the "Add Expression" button.
Select the attribute "capacity" and set the corresponding value to "6.5". Also make sure that the condition is set to ">=" (greater and equals than).
This mathematical condition is only selectable if the attribute "capacity" has the type "Number" (see Data Attributes Table).
- Afterwards both attributes and their values are attached to the "yes" option.
- Of course you can add further expressions.
As already mentioned earlier: All non-selected values, e.g. like "capacity less than 6.5" are automatically attached to the invisible "no" Answer Option. That is why it is unnecessary to implement this state in the Question card.
If you have configured a Boolean Answer Option Type, the following applies:
- There is only one system-generated Answer Option ("yes"). It is not possible to add further Answer Options or to delete the existing Answer Option.
- The option "The user can select ..." (see General Properties) will be disabled with the fixed value "one answer". This is needed because only one state can be selected at the same time.
- All Boolean Questions can be mapped into "classic" Questions with two Answer Options. However they differ in the recommendation behavior.
- The combination of answer option mapping Automatic and Answer Option type "Boolean" is not allowed.