List of texts datafield that combines predefines and free values

I want to use a list of texts datafield where I provide some predefines and allow the user to give a free input at the same time.

My condition is the following:

{‘administration’ in #costs^included: administration costs | ‘phone’ in #costs^included: telephone and GSM charges | ‘car’ in #costs^included: car expenses | ‘travel’ in #costs^included: other travel expenses | else: #costs^included}

#costs is a list of texts datafield, but when I select all the predefines in the datafield-pannel, the only text that appears is “administration costs”, which is the first one.

How can I resolve this issue in order that all selected predefines appear in the document + freely added input appears in it too?

Hi Isha,

When you create a condition with lists of texts like this one, ClauseBase will read it from left to right. As soon as it finds a value that has been filled out, it will stop reading the rest of the condition. In other words, if the value “administration” has been filled out, it will stop reading the rest of the condition and simply use that value. If the value “phone” has been filled out, it will stop reading everything after “phone”, etc.

The solution is to include these separate subconditions into an enumeration, where each individual element of the enumeration is conditional.

Then, you still have to use a separate datafield for your “free” input (i.e.: the input that users can give without being restricted to the predefines). It is important to place that conditional “free” input field first in the overarching enumeration because otherwise, ClauseBase will not correctly apply the “; and” at the end of the enumeration since it can only read these elements as individual subelements (i.e. each “leg” of the {AND | … | … | …} will be regarded as an individual element, even though it contains a list). So to make sure the “; and” will be placed correctly, it is important to make sure that the free input list of texts datafield is not the final element. If you experiment with this, you will immediately see the difference.

The final potential hurdle is that none of the predefined fields in #costs^included are used, in which case a simple #costs^included-free would not yield the desired result. That’s why you also have to incorporate a condition that explicitly creates an enumeration in that situation by including “#costs^included = false:”. If you would not do this, #costs^included-free would be an enumeration without the “and” before the final item.

In short, that gives the following result:

1. {AND | {#costs^included-free AND #costs^included = false: @enumerate-and(#costs^included-free) | else: #costs^included-free } | {"administration" in #costs^included: administration costs} | {"phone" in #costs^included: telephone and GSM charges} | {"car" in #costs^included: car expenses} | {"travel" in #costs^included: other travel expenses} }

For a more detailed overview of this topic, be sure to check out the advanced How To on this subject in the Help Center: https://help.clausebase.com/kb/how-to-create-a-list-with-both-predefined-options-and-free-input/