Conditions, calculations and validation
A form can change with the person’s answers: “If the expense type is Yol, show the Güzergâh question”, “If the total goes over 5,000 TL, make Gerekçe required”. You set up these rules without writing code, with short expressions. The rules work the same way on the filling screen, in the mobile app and on the Defthand server; even if someone gets around a rule in the browser, the submission is checked again on the server.
This page covers three things: attaching a condition to an element, the actions and variables in the form’s Logic view, and how expressions are written.
Attaching a condition to an element
Section titled “Attaching a condition to an element”- Select the element in the designer.
- Open the Logic heading in the Properties panel.
- Type the expression into the box of the setting you want. Under an invalid expression, the reason is shown.
| Setting | What it does | Notes |
|---|---|---|
| Visible when | If the expression is true the element shows; if false it is hidden. | By default the answer of a hidden element does not go into the submission (form setting Answers of hidden fields). A hidden question is not asked for even if it is required. |
| Enabled when | If the expression is false the element shows but is disabled and cannot be filled. | |
| Required | When on, the question is always required. | The Required button in the toolbar is the same setting. |
| Required when | If the expression is true the question becomes required. | If Required is on, this condition is ignored. |
| Required message | Your own text shown when the question is left empty. | Example: “Plaka olmadan kontrol kaydedilemez.” If empty, the standard message appears. |
| Read-only when | If the expression is true the element becomes read-only; its value shows but cannot be changed. | |
| Calculated value | The question’s value is always the result of this expression. | The person cannot change it. See below. |
| Default value | The question’s starting value when the form opens (an expression). | The person can change it. Example: today(). |
| Reset when | When the expression becomes true, the answer is cleared. | Example: when masraf_turu != "yol", the route question is emptied. |
Pages and Sections also have a Visible when condition; a hidden page is skipped on the filling screen. In choice questions each option has its own visibility and enabled conditions, and an Elements it opens setting (see Choice fields).
The Dynamic label and Dynamic description settings let you bring the answer to another question into the label or description text; for example “34 ABC 123 plakalı aracın kilometresi”. If this setting is filled, the filling screen uses it, while reports and exports use the plain Label.
Calculated values
Section titled “Calculated values”There are two ways:
- The Computed value element (under Display in the toolbox) shows the result of an expression and writes it into the submission. First choose the Result type (Text, Number, Yes / No, Date, Date and time, Time), then type the expression into Logic → Calculated value. Details: File, display and device elements.
- If the Calculated value setting of any input question is filled, that question becomes read-only and its value is calculated.
Example, the total of the items in an expense form:
sum(kalemler[*].tutar)Calculated values are calculated again on the server when the form is submitted; the stored value is always the one the server calculated.
The Logic view
Section titled “The Logic view”The designer’s Logic view gathers all the rules of the form in one list: the elements’ conditions, calculated values, validators, actions and variables.
- In the New rule section, choose Which element or page and Which rule, then click Add rule to write a condition on an element. The same section also has Add variable, and Action type with Add action.
- In Filter the rules, narrow the list with Search, Element and Rule type.
- On each line, Edit opens the expression in place and Show in design takes you to the element.
- A change you make here changes the rule where it is written; Undo works in both places.
- Expressions that read each other and cannot reach a result (a loop) are shown at the top of the list; the form cannot be published until they are fixed.
Variables
Section titled “Variables”You define a variable to give a name to a calculation you use in more than one place.
- Click Add variable in the New rule section of the Logic view, or in the Variables section of the Properties panel with Form selected.
- Key: the variable’s name, for example
kdv_dahil_toplam. It must start with a lowercase letter and may contain letters, digits and underscores. - Expression: the variable’s value, for example
ara_toplam * 1.2. - Write to the result: if you tick it, the variable’s value is stored with the submission; if not, it is only calculated inside the form.
You refer to variables in other expressions by their key. A form can have at most 100 variables.
Actions
Section titled “Actions”An action is an operation that changes the inside of the form when a condition is true. Actions do not send email and do not write anything outside the form; for that there are submission notifications and approval workflows.
- In the New rule section of the Logic view, choose the Action type and click Add action. (You can do the same in the Actions section of the Properties panel with Form selected: Type of action to add, Add action.)
- In the When box, type the condition under which the action runs. It must be an expression whose result is Yes or No, for
example
km_sayaci > 15000. - Fill in the settings of the type:
| Action | Settings | What it does |
|---|---|---|
| Write a value | Target field, Expression | When the condition is true, writes the result of the expression into the target field. |
| Copy a value | Source field, Target field | Copies the answer from the source to the target (such as “billing address is the same as the delivery address”). |
| Clear | Target field | Deletes the answer of the target field. |
| Skip to a page | Target page | When the person moves to the next step, they skip the pages in between and go to the target page. |
| End the form here | Skips the remaining pages; the person goes straight to the submit step. | |
| Run an expression | Expression, optional Target field | Calculates the expression; if a target is given, writes the result there. |
A form can have at most 200 actions. To delete an action, use the delete button on its line. A missing setting is shown in the issue list.
Writing expressions
Section titled “Writing expressions”Referring to questions
Section titled “Referring to questions”- You refer to a question by its key:
toplam,masraf_turu. The key is in the element’s General settings. If you change a key, the expressions that read it are updated automatically. - A question inside a Field group is reached with a dot:
adres.il. - The columns of Repeating rows and Table elements are lists:
kalemler[*].tutaris the amount of every row,kalemler[0].tutarthe first row,kalemler[-1].tutarthe last row. In an expression inside a row (for example in a column’s calculated value) you reach the columns of the same row directly:birim_fiyat * adet. - To filter rows, write
[? condition]:sum(kalemler[? tur == "yakit"].tutar),count(kalemler[? tutar > 1000]).
Values
Section titled “Values”| Type | How to write it |
|---|---|
| Text | In double quotes: "yol". Single quotes are not used. |
| Number | The decimal separator is a dot: 5000, 0.18. Thousands separators and notation such as 1e3 are not used. |
| Yes / No | true, false |
| List | Square brackets: ["yol", "konaklama"] |
| Date and time | With conversion functions: date("2026-12-31"), time("08:30"), datetime("2026-12-31T08:30:00+03:00") |
In choice questions what you compare is the option’s value, not its label: for an option labelled “Yol” with the value yol,
write masraf_turu == "yol". The value of a multiple choice is a list: "klima" in donanimlar.
Operators
Section titled “Operators”| What | Operator | Example |
|---|---|---|
| Comparison | == != < <= > >= |
toplam > 5000, il != "ist" |
| In a list | in |
masraf_turu in ["yol", "konaklama"] |
| And, or, not | and or not |
toplam > 5000 and not faturali |
| Arithmetic | + - * / % (remainder) |
birim_fiyat * adet |
| Joining text | + |
ad + " " + soyad |
Precedence from weakest to strongest: or, and, not, comparisons, + -, * / %. When in doubt, use parentheses. &&,
||, a single = and chains such as 1 < x < 3 are not used; write the last one as x > 1 and x < 3.
Rules to know:
- Text comparison is case-sensitive:
"Yol" == "yol"is false. - Types do not convert on their own: you cannot compare a number question with text (
toplam == "6000"gives an error). Usenumber(...)ortext(...)when needed. - You cannot add a number to a date; use
dateAdd. A date and a date-time cannot be compared with each other. - Decimal arithmetic is exact:
0.1 + 0.2 == 0.3is true. Dividing by zero gives an error.
Empty values
Section titled “Empty values”An unanswered question is empty. Empty text ("") and an empty list also count as empty; 0 and false are not empty.
- A calculation with an empty value gives an empty result: if
adetis empty,birim_fiyat * adetstays empty. - Every comparison with an empty value is false,
!=included: ifindirimis empty, bothindirim == 0andindirim != 0are false. To test for emptiness, useisEmpty(indirim)ornotEmpty(indirim). - Aggregate functions (
sum,count,min,max,avg) skip empty values. If there are no values at all,sumgives 0 andavggives empty. - If the condition of
ifis empty, the second (otherwise) value is chosen.
Functions
Section titled “Functions”| Function | What it does | Example |
|---|---|---|
if(condition, a, b) |
a if the condition is true, otherwise b. Both values must be of the same type. |
if(toplam > 5000, "Finans", "Yönetici") |
isEmpty(x), notEmpty(x) |
Is it empty, is it filled | isEmpty(aciklama) |
sum, min, max, avg, count |
Total, smallest, largest, average, number of filled items in a list | avg(kalemler[*].puan) |
round(x, places), trunc(x, places) |
Rounds (halves away from zero), truncates | round(toplam * 0.2, 2) |
abs(x) |
Absolute value | abs(fark) |
today() |
Today’s date | teslim_tarihi >= today() |
dateAdd(date, n, "unit") |
Adds days, months, years to a date (whole numbers) | dateAdd(today(), 7, "day") |
dateDiff(start, end, "unit") |
The number of whole units between two dates; negative if the end is earlier | dateDiff(baslangic, bitis, "day") + 1 |
age(birth, date?) |
Age in completed years; relative to today if no date is given | age(dogum_tarihi) >= 18 |
year, month, day, weekday |
Year, month, day, day of the week (Monday 1, Sunday 7) | weekday(tarih) <= 5 |
hour, minute |
Hour and minute | hour(baslama_saati) >= 8 |
length(x) |
The number of characters in a text or of items in a list | length(aciklama) >= 20 |
substring(text, start, length?) |
Part of a text (start counted from 0) | substring(plaka, 0, 2) |
lower(text, language?), upper(text, language?) |
Converts to lowercase or uppercase | upper(il, "tr") |
trim(text) |
Removes spaces at the start and end | trim(ad) |
replace(text, search, new) |
Replaces every occurrence (plain text) | replace(telefon, " ", "") |
contains, startsWith, endsWith |
Contains, starts with, ends with | startsWith(plaka, "34") |
displayValue(choice) |
The label of the chosen option, in the form’s language | "Tür: " + displayValue(masraf_turu) |
anyOf(list, candidates) |
Is any of the candidates in the list | anyOf(arizalar, ["fren", "lastik"]) |
allOf(list, required) |
Are all the required items in the list | allOf(kontroller, ["far", "silecek"]) |
number, text, date, datetime, time, bool |
Convert a type; a value that does not convert becomes empty | text(toplam) + " TL" |
isVisible, isEnabled, isReadOnly, isRequired |
The current state of an element | isVisible(guzergah) |
Units for dateAdd and dateDiff: for dates "day", "month", "year"; for date-times also "hour", "minute", "second".
The unit is always written as a fixed value in quotes. Adding months is clamped to the end of the month: adding one month to
January 31 gives the last day of February. date("...") only reads the year-month-day format (2026-12-31); 31.12.2026
returns empty.
Special values
Section titled “Special values”| Value | Meaning |
|---|---|
$now |
The current time (date-time). |
$locale |
The language the form is being filled in at the moment, for example "tr-TR". |
$user.id, $user.employeeId |
The identity of the person filling in the form and the employee record linked to their account. |
$row.index |
The position of the repeating row (starts at 0). Only inside rows. |
$prev, $next |
The previous and next row: $prev.km_bitis. In the first row $prev is empty. |
$form.mode |
The mode the form was opened in ("edit" while filling in). |
Limits and errors
Section titled “Limits and errors”An expression can be at most 2,000 characters; very deeply nested parentheses and very long constant lists are refused too. The designer checks the expression while you type and shows errors under the expression and in the Issues list:
- an unknown key or function,
- a type mismatch (comparing a number with text, the two values of
ifbeing of different types), - writing that cannot be read: “This expression cannot be read (character N). A draft can hold it; publishing cannot.”
An invalid expression can stay in the draft, but the form cannot be published.
Validation
Section titled “Validation”There are two ways to limit the answer to a question.
Built-in limits. The element type’s own settings: Minimum and Maximum (number, date, time), Maximum characters, Minimum selected and Maximum selected, Input mask, file types and size. Each type’s limits are described on its own page.
Validators. Under Properties → Validation → Validators, choose a Validator to add and click Add validator. An element can have at most 10 validators.
| Validator | Settings | What it checks |
|---|---|---|
| Text length | Minimum, Maximum | The number of characters in the answer. |
| Number range | Minimum, Maximum | That the number is in the range. |
| Regular expression | Pattern (at most 500 characters) | That the answer matches the pattern; for example ^[0-9]{2} [A-Z]{1,3} [0-9]{2,4}$ for a plate format. |
| Email format | That the answer is a valid email address. | |
| Expression | Expression | That the expression is true; for example donus_tarihi >= gidis_tarihi. |
| Answer count | Minimum, Maximum | The number of options chosen in a multiple choice, or the number of rows in an element with rows. |
Every validator has two common settings:
- Severity: Error stops the submission and moving to the next page. Warning and Info only show a message; the person can go on.
- Error message: the text the person sees, for example “Dönüş tarihi gidiş tarihinden önce olamaz.” If empty, the standard message appears.
When validation happens is set by the form’s Check for errors setting: On next step (default), When a value changes or On submit. See Common element, page and form settings.
If a required question is empty or a validation fails, the person cannot move to the next page; the error summary at the top of the page lists that page’s errors and takes them to the question. The server checks the submission again with the same rules.
Examples
Section titled “Examples”| Need | Where | Expression |
|---|---|---|
| Ask for the route if the expense type is Yol | guzergah → Visible when |
masraf_turu == "yol" |
| Reason required above 5,000 TL | gerekce → Required when |
toplam > 5000 |
| Number of leave days | gun_sayisi → Calculated value |
dateDiff(baslangic, bitis, "day") + 1 |
| End cannot be before start | bitis → Expression validator |
bitis >= baslangic |
| No weekend dates | tarih → Expression validator |
weekday(tarih) <= 5 |
| Clear the description if there is no fault | ariza_aciklama → Reset when |
ariza_var == false |
| A row gets the previous row’s end mileage | km_baslangic (in the row) → Default value |
$prev.km_bitis |
| Under-18s cannot apply | dogum_tarihi → Expression validator |
age(dogum_tarihi) >= 18 |
Testing the rules
Section titled “Testing the rules”In the Preview view you fill in the form and see how the rules work; Show hidden elements shows the hidden questions too. For lasting checks you can write scenarios in the Tests view; details on the Publishing and versions page.