These two rules are used in a similar manner to .appear() and .disappear(). The main difference is that unlike .appear and .disappear, .forceAppear and .forceDisappear will not perform the opposite action when their condition is false. They can be used with Q(), Section(), QRange() and QOrder(). Some examples of how .forceAppear and .forceDisappear can be used:

//If answer 1 is chosen for Q(21), hide Q(31), otherwise, show Q(31)
ifQ(21)
.answered(1)
.disappear(Q(31));


In the example shown above (using .disappear rather than .forceDisappear), if the shopper selects answer 1 for question 21, question 31 will disappear. If the shopper then changes their answer to something other than answer 1, question 31 will reappear.

//If answer 1 is chosen for Q(21), hide Q(31)
ifQ(21)
.answered(1)
.forceDisappear(Q(31));


In the second example, if the shopper selects answer 1 for question 21, question 31 will disappear and will not reappear if the answer is changed to something other than 1.



Here's another illustration where question 31 is a Yes/No question (i.e. it only has two possible responses):

//If answer 1 is chosen for Q(21), hide Q(31), otherwise, show Q(31)
ifQ(21)
.answered(1)
.disappear(Q(31));


//Same as above, but implemented with .forceAppear and .forceDisappear

ifQ(21)
.answered(1)
.forceDisappear(Q(31));


ifQ(21)
.answered(2)
.forceAppear(Q(31));


The examples above show how the .appear rule is equivalent to the combination of a .forceDisappear and a .forceAppear rule. As you can see, using .disappear (and .appear) require fewer lines of code, but .forceAppear and .forceDisappear are can offer more specific control.



When To Use .forceAppear and .forceDisappear


There are several situations where one might want to use .forceAppear or .forceDisappear instead of .appear or .disappear.


The most useful case is to avoid multiple-rule conflicts. Consider the following:

ifQ()
.waveIS("Round 4")
.disappear(Q(11), Q(21));


ifQ()
.groupIS("Combo Store")
.disappear(Q(21), Q(31));


Notice that in the above rules, Q(21) is disappeared in two different rules. This can cause a conflict if the first rule is true and the second is false (the first rule would tell Q(21) to disappear and the second rule would tell Q(21) to appear). However, if you change the effect to .forceDisappear:

ifQ()
.waveIS("Round 4")
.forceDisappear(Q(11), Q(21));


ifQ()
.groupIS("Combo Store")
.forceDisappear(Q(21), Q(31));


These rules will no longer conflict, as the rules will only hide the question if the condition is true and do nothing else.