Dynamic conditions: builder

Dynamic conditions change the task form at runtime based on what the solver fills in: they hide fields, change whether fields are required, check entered values, calculate values or limit the options offered in lists. You set them up in the Conditions window, which you open with the Conditions button in the task editor toolbar. The window has two tabs: Builder for building conditions from blocks without programming, and Script for custom code. Automatic tasks do not have this button. For a new task, the window opens only after the task is saved.

The Conditions window and the Builder tab

No.ElementPurpose
1All activeTurns off all blocks at once. When you turn it back on, only the blocks that were active before are reactivated. Builder tab only.
2CloseCloses the window. If there are unsaved changes, it asks Save changes?: Confirm saves them, No discards them.
3DeleteAfter confirmation, deletes all blocks, the entire script and the loaded scripts. The change takes effect only after saving.
4SaveSaves the conditions and leaves the window open.
5Save and closeSaves the conditions and closes the window.
6BuilderThe tab with blocks. The window opens on this tab.
7ScriptThe tab with the complete condition code.
8Loaded scriptsSelection of scripts from administration that are loaded for this task. The number shows how many are selected.
9HelpOpens help for the builder or the script, depending on the active tab.
10Search variableShows only the blocks that change the selected variable. While searching, you cannot add or move blocks.
11FunctionWhat the block does; see the table of functions.
12VariableThe variable the block acts on.
13ActiveTurns a single block on or off. A disabled block stays saved but is not executed.
14DuplicateCreates a copy of the block.
15Convert to scriptConverts the block to a Script block with generated code.
16Delete blockRemoves the block.
17MoveDrag the icon to change the order of the block.
18Condition variableThe variable whose value is compared in the condition.
19OperatorThe comparison method; see below. Active after a variable is selected.
20ValueThe value to compare with. Depending on the variable type, this is a field, a selection from a list or a date.
21Compare with variableSwitches the Value field to selecting another variable, for example the return date must be greater than the departure date. Offers only variables of a suitable type.
22Add conditionInside a block, adds another group of conditions. At the bottom below the blocks, adds a new block with the Hide function.
23Run on changeWhen you turn this option on and select variables, the block is evaluated only when these variables change.

Each condition row also has icons for deleting the row, moving the row and adding another row after it. Rows within one group are joined by the selected operator AND or OR; between groups, you choose the same at block level. The editor highlights unfilled required block fields in red and does not save the conditions.

Block functions

FunctionWhat it does in the formConnector after the variable
HideHides the variable when the condition is met.when
ChangeSets a new value for the variable when the condition is met. For value types, see below.to
ValidateChecks the value of the variable and shows a message on error. It has no condition part.that
FilterLimits the values offered in a list when the condition is met. Only for dynamic lists, dynamic tables and lists of texts, numbers and dates.so that
Read-only variableSwitches the variable to read-only mode when the condition is met.when
Writable variableSwitches the variable to write mode.when
Required variableMakes the variable required.when
Allow completion on changeWhen the condition is met, the task completion buttons are active; otherwise they are inactive.when
ScriptFree-form code. Instead of fields, it has a code editor and the Add variable and Demo code icons.–

Condition operators

OperatorFor which variables
equals, does not equalAll except document lists, checkboxes and dynamic rows.
greater than, greater than or equal to, less than, less than or equal toNumbers, dates, lists of numbers and dates.
contains, does not containText and multi-value variables.
is empty, is not emptyAll. For checkboxes, these are the only operators offered and mean unchecked and checked.

For dates, the Value field offers Today, Yesterday, Tomorrow, Previous working day, Start of month, End of month, Start of year, End of year and Date for selecting a specific day. Relative dates are calculated at the moment of evaluation.

Validate

No.FieldPurpose
1ValidationType of check. The options depend on the variable type; see below.
2ValueThe limit or length to compare with.
3Validation error messageThe text the solver sees next to the field when the value fails the check. The field is for the first system language. The message is optional.
4Other language variantsOpens the messages for other languages. The AI translation button fills them in if AI is enabled.
Variable typeValidations offered
AllEquality with another variable
Text, single-value text listE-mail, Phone number, URL address, exact, minimum and maximum text length, Letters only, Letters and numbers, Date
Number, single-value number listMinimum value, Maximum value
Number, date, lists of numbers and datesLess than, Greater than, Less than or equal to, Greater than or equal to. For dates, you choose a quick date or a specific day as the limit.
Apostrophe in the message
The message is stored in the condition code in single quotes. Do not use an apostrophe in it; it could break the condition code.

Change

The Change function sets the variable's value from one of these sources. The options depend on the type of the target variable:

SourceResult
ConstantA fixed value.
Dynamic linkA link to a case, task or overview based on the number from the selected numeric variable. Text variables only.
Number operationsA calculation from two variables: what % of, by what % it differs from, what % remains, add, subtract, multiply, divide.
Dynamic dateA quick date, or a date from another variable plus or minus a specified number of days.
User, organizational unit or role parameterInformation about a user, unit or role based on the ID in another variable, for example e-mail, display name or unit manager.
Value from dynamic tableThe value from the selected column of the first table row that matches the filter. The table can also be selected dynamically with an expression containing variables.
Variable valueA copy of another variable's value.

Filter

A filter consists of rows with Parameter or Column, Operator and Value. For a dynamic list of users, units or roles, you filter by their properties; for a dynamic table, by columns; for lists of texts, numbers and dates, by value. The value can also be compared with another variable. The New filter button adds another group. If you change the target variable to a different kind of list, the filter is cleared.

What the builder cannot do
The builder has no dedicated blocks for sections, buttons, dynamic row columns or URL calls. You write such behaviour in a Script block or on the Script tab. The builder itself loads data from dynamic tables and user parameters as part of the Change and Filter functions.

The Script tab

No.ElementPurpose
1Add variableInserts the name of the selected variable into the code.
2Demo codeInserts sample calls of condition functions.

The tab shows the complete condition code. The code editor suggests variable and function names.

How the builder and the script work together

The builder and the script store one shared piece of code. Each builder block is written to the code as one function call marked with the @BuilderBlock comment. A disabled block is written as commented-out code marked with @BuilderInactive.

  • When you switch to the Script tab, the blocks are converted to code.
  • When you switch back to Builder, the marked calls are converted back to blocks. Code between them that the builder does not recognise is shown as Script blocks.
  • If you edit marked code so that the builder cannot understand it, the message Script to builder conversion failed is shown and you stay on the Script tab. The same happens when the window is opened.
  • You convert a single block to a script with the Convert to script icon. You convert a Script block back with the Convert to structured block icon if it contains exactly one marked call.

On the Builder tab, required block fields are checked before saving. On the Script tab, the code is saved exactly as written.

Window for a single variable

On the Assignment tab, variables affected by a condition have a number next to their name. Clicking it opens the Conditions window with the Search variable field filled in: you see the blocks that change this variable, as well as Script blocks whose main call lists it first. Blocks in which the variable appears only in the condition part are not shown. The number on the Conditions button in the editor toolbar counts all condition function calls in the code; disabled blocks are not counted.

Example: converted forms of the purchase order template

The forms of the sample template “TAS | Purchase Order 5.19” have been converted to the builder. The Create new PO task combines a Script block with custom code and structured Hide blocks that run when a variable changes.

Help

The builder help has a search and a chapter for each function with a sample block. The Use in builder button next to a sample adds a block with that function to the end of the builder. The Functions and Services links open a detailed overview of functions for the script.

How to add conditions in the builder

In the sample template “Travel request”, the Fill in the travel request task has two blocks: it hides the Visa required field when the means of transport is a company car, and it does not allow an estimated cost above CZK 200,000.

  1. Open the task and click Conditions.
  2. Click Add condition below the blocks. A block with the Hide function is added.
  3. Select the Visa required variable. In the condition row, select Means of transport, the equals operator and the value Company car.
  4. Click Add condition again, change the function to Validate and select Estimated cost.
  5. As the validation, select Maximum value, enter 200000 and write a message. Use the Other language variants link to add the message in other languages.
  6. Click Save and close.

The Loaded scripts window selects which active dynamic condition scripts from administration are loaded in the task. If you select none, all of them are loaded.

Related: Assigning variables and sections, Calculations on a task, Calculations and scripts section.

Planning: start, branching and due date

Variable assignment and sections

Syca (opens in a new tab)

Powered by HelpDocs (opens in a new tab)