Adding conditions to cards, questions and change sets

  • Home
  • Q&A
  • Adding conditions to cards, questions and change sets

Cards and/or questions (and even predefined options within a question) can be made conditional so that they are only shown in the Q&A form if the condition is fulfilled.

Similarly, change sets can also be made conditional, so that they will only be applied when the specified conditions are met.

Enabling conditions

Select the card, question or change set that you want to apply the condition to and click the   button. (If you want to apply a condition to a predefined option within a question, click at the right side of the predefined option.) Now the conditions frame will be visible.

Choose here whether all of the listed conditions have to be met (conditions shown in yellow), whether it suffices that any of them are met for the card/question to be visible (conditions shown in green), or whether none of them may be met for the card/question to be shown (conditions shown in gray).

Simple conditions or groups

You can add one or more “simple” conditions, add groups of conditions (which are evaluated together) or make a combination of both. 

An (additional) simple condition is created by clicking , while a group is created by clicking .

It is important to note that subgroups of conditions are evaluated together. A choice will again need to be made whether the conditions in the subgroup should all be met, whether any of them should be met or whether none of them may be met.

Configuring a condition

A condition can be tied to several elements:

  • the answer to a question
  • whether another question is visible (i.e. the conditions for that question are fulfilled)
  • whether another card is visible (i.e. the conditions for that card are fulfilled)
  • the output language (language of the document being made)
  • the interface language (language of the Q&A form, depending on user preference)
  • user tags (i.e., the combination of all tags assigned by the customer’s administrator, either directly to the user, or to the groups of which the user is a member, or to the customer itself)

Answer to question

Makes the card/question conditional upon the answer of a question. There are several types of ways a condition can be evaluated, depending on the type of question that it will be tied to.

For example, a condition tied to a “date” type question can be evaluated to be equal to, before, before or at, later than,  later than or at another date. A condition tied to “text” type question can be evaluated to be equal to, not equal to, containing a certain text fragment or not containing a certain text fragment.

For all types of questions a condition can be tied to whether an answer was specified or not specified.

Deleting conditions

A (set of) condition(s) can be deleted easily by clicking the garbage can  icon next to the condition you want to be deleted.

Disabling all conditions

If a card/question should be shown unconditionally (i.e. in all cases), or if you want a change set to always be applied, then you can simply uncheck the checkmark here:This will remove all conditions and make sure the selected card/question will always be shown (or, in the case of change sets, that the changes within the set will always be applied).

Copying and pasting conditions

When you hover your mouse over the set of conditions for a card/question or over an individual condition, the copy button   will become visible.

Having clicked the copy button, the paste button  will become visible as well. Clicking it will paste the (set of) condition(s) that you copied in the location that you indicated.

Expression conditions and table column visibility conditions

A special type of condition is a an “Expression” condition. This is a somwhat advanced condition, but you can achieve powerful results with it that go beyond “normal” conditions.

The main limitations of “normal” conditions are that you can only compare answers and enabled-states with “simple” values, such as numbers or texts — e.g. you cannot compare an answer to some other answer. In addition, the number of operators that can be used during the comparison, is limited to the usual suspects: equal, not equal, part of, and several mathematical operations (larger than, smaller than, etc).

With expression conditions, you can avoid this limitation. The idea is that you write a Q&A condition in a way that is similar to how you write a condition within the curly braces { ...} of actual clauses. When doing so, you can use most of the special functions, in particular the following ones:

  • @card-enabled and @question-enabled — take a single parameter (the identifier of the card or question) and return true/false, depending on whether the card/question is currently enabled.
  • @shared-condition —also takes a single parameter (the name of the shared condition, see explanation below) and returns true/false, depending on whether the shared condition returns true/false.
  • @column — also takes a single parameter (the identifier of the column), and returns the value of the current table row’s cell in the specified column. This function can only be used within the visibility condition of a table cell.
  • @answer
    • When used with a single parameter (the question’s identifier), it returns the current answer to the question with the specified identifier.
    • When used with two parameters (the question’s identifier and the column’s identifier), it returns a list with all the values in the specified table column. This will only work when the specified question is a table-based question.
    • When used with three parameters (the question’s identifier, the column’s identifier and the number of the row), it returns the cell’s value at the specified location in the table. This will only work when the specified question is a table-based question.

Tip: the identifier of a card can be set in the card options. The identifier of a question can be set in the Interaction settings of the question’s options.

The identifier a table column can be set in the “…” popup menu next to the table column. There, you can also specify the table column’s visibility condition.

Please note that, when invoked in the context of a Q&A, the special functions do not have access to the underlying document. So even if your underlying document would define a concept #contract, that concept will not be usable in the expression conditions of a Q&A — accordingly, a call such as @implemented(#contract) will always return false, because the expression condition operates in a special context, in which it only has access to the questions & answers of the Q&A.

Example: identical answers

You have two questions, asking for the name of Manager 1 (identifier “m1”) and the name of Manager 2 (identifier “m2”). If it often happens that users make the mistake of filling in the same name in both questions, you could add a warning (e.g., “Alert! You have specified the same name twice!”) with an expression condition set to

@answer("m1") = @answer("m2")

Or you could even write the following, to prevent that the warning would be shown with two empty answers:

@answer("m1") AND @answer("m2") AND (@answer("m1") = @answer("m2"))

Example: avoid that an answer starts with a certain letter

A warning with the following expression condition would only be shown when the answer starts with the letter “R”:

@lsub(@answer("some-answer"), 1) = "R"

Example: avoiding the outcome of a calculation

Assume you are automating a shipping contract and want to ask a true/false question “Heavy-weight shipping option to be used?”, that should only be shown when the package exceeds 100 kg. If you have a question asking for the number of items to be shipped (identifier “unit-count“) and another question asking for the weight of a unit (identifier “unit-weight”), then you could subject the true/false question regarding the heavy-weight shipping option to the following expression condition:

@answer("unit-count") * answer("unit-weight") >= 100

Example: only showing a certain table column when another value in the same row is checked

For example, assume you have a first column “Legal entity?” (with identifier “legal-entity”) and another column “Owner name” (with identifier “owner”), and you only want to aks for the owner when the legal-entity box is checked:

@column("legal-entity") = true

or even shorter:

@column("legal-entity")

These expressions can simply be inserted into the table column’s visibility expression.

Example: showing a warning when percentages do not add up to 100%

For example, when you have a column “Shares percentage” (identifier “shares-pct”) that you always want to add up to 100%. You could then insert a warning with the following condition:

@sum(@answer("shares-table", "shares-pct")) != 100

A bit more advanced is to also check whether something is filled in in the table (otherwise the warning would also show up if nothing is filled in yet):

@answer("shares-table") and @sum(@answer("shares-pct", "shares")) != 100

Note: invoking @answer with a table-identifier will return true if the table has something filled in.

Similarly, you could envisage disabling subsequent questions (see below) if the 100% is not met.

Example: asking for a special provision when a certain jurisdiction is chosen

Assume that you have a table-based question (identifier “items-table”) in which the end-user can specify in a certain column (identifier “jurisdiction”) the jurisdiction where a certain service will be delivered.

If you then want to ask an additional question, regarding a special Italian provision to be inserted when “Italy” would be selected as one of the jurisdictions, you could write in the expression condition for that additional question:

"Italy" in @answer("items-table", "jurisdiction")

Example: showing a warning when the end date is beyond 2023

Assume you have two questions in which you ask for the commencement date (identifier “commencement-date”) and the duration (identifier “duration”).

If you want to show a warning when the end date would be beyond the end of 2022, you could write:

@answer("commencement-date") + @answer("duration") >= 2023_01_01

Sharing conditions

Copying and pasting conditions between questions/cards/change-sets is very easy — in fact, it is so easy that it is a no-brainer to copy-paste the same condition in many different places.

This is fine for trivial Q&As, but from a maintenance point of view, this quickly becomes dangerous in a complex Q&A with many different questions, cards, predefines and change-sets.

Assume that you have a non-trivial set of conditions that specifies that the fee must be higher than 2500 EUR, the commencement date must be known and some duration must be set. Also assume that you have copy/pasted this condition set to 45 different items in the Q&A. You can be almost certain that at some point in time, the company’s policy on the 2500 EUR fee will get changed — e.g., into 3000 EUR, with the additional caveat that a third subcondition regarding the late interest amount must be added as well. Now imagine the amount of work involved when you have to apply these two changes 45 times…

This is where shared conditions are designed for. By showing the repository pane and going to the subpanel shared conditions, you can add a shared condition. It works exactly in the same way as the regular conditions, the only difference is that you have to give it a name — in fact, it is probably a good idea to simply copy/paste the condition-set from a certain item once you know that item’s condition-set is properly working.

Next, you can use that condition-set as a regular condition in any location within the Q&A:

The shared conditions have two distinctive advantages from a management & maintenance point of view:

  • You can centrally change a shared condition, so that you don’t have to manually hunt for all the locations where a certain condition-set happens to be used.
  • You can assign a descriptive label to help understand the purpose a complex condition-set. This may sound trivial, but if you have a very complex set of conditions with many different sub-conditions, it may not be obvious to some colleague who maintains that Q&A in the future what the condition-set is really about. Also, do not understand how little future-you-in-six-months will remember about a complex condition-set that may seem obvious to you today.

Disabling subsequent questions

Due to their inability to show real-time interacting questions and text previews, most competing document automation platforms require users to answer Q&As in a “step-by-step” fashion, where a certain question must be answered before subsequent conditions can be answered.

We are convinced this leads to “questionnaire fatigue” for your users, because users do not know upfront how many questions will need to be answered. Also, going back/forth tends to be slow, or is even actively avoided by users who have been traumatised by old-style questionnaires that forget all answers when you hit the back-button.

ClauseBase takes the opposite approach: if possible, you should be able to see all questions upfront, and be allowed the possibility to answer them in any order. Where necessary, you can easily define that certain cards/questions/predefines should be hidden until some preceding question is completed.

Even though copy/pasting conditions and using the aforementioned shared conditions easily allow you to create questionnaires that hide subsequent questions until a certain preceding question is completed, this can become cumbersome in complex questionnaires with many different cards, because the same (shared) condition must be copy/pasted onto many different items.

ClauseBase therefore allows you to specify for a specific question A that, until that question A is answered, all subsequent conditions B, C, D, … must be disabled (i.e., hidden). You can even choose whether all subsequent questions in the entire Q&A must be disabled, or only the questions in the same category of cards, or only the neigboring questions in the same card.

You can do so, by setting the If empty option of the Interaction section of a question’s options.

Note that this takes the opposite approach: instead of imposing the condition “A must be answered” on questions B, C, D, … you enable this “disable subsequent questions” feature within question A.

While very powerful, please use this option sparingly, particularly the “disable all subsequent questions” suboption. The aforementioned “questionnaire fatigue” is a real issue that we have witnessed many times in competing systems, even causing users to reuse old Word-files instead of completing a questionnaire.

The typical use case is for an introductory question in a card/category on which several subsequent questions depend — e.g., a question “Does the employee have a company car?” that should hide several questions relating to the company car if no car is granted to the employee.

The “if empty” action effectively operates as an implicit condition that is checked in addition to all the other conditions that may get imposed on subsequent questions (or their cards).

Was this article helpful?
Dislike
Types of changes
Question options