# Expression language

**The conditional expression language in Eximee** allows conditional logic to be defined (e.g. field visibility, enabled state, requiredness) using JavaScript syntax extended with specific methods. Conditions are written as expressions that the platform **Eximee** checks during application runtime. Below is a description of the syntax, available methods and attributes, as well as tools that make it easier to create and test conditions.

## Conditional expressions in Eximee

* **JavaScript in conditions:** All conditions in the request template can be described using JavaScript expressions. This means that in the condition field we can use standard operators (`==`, `!=`, `>`, `<`, `&&`, `||`, `!`) and JavaScript functions. The syntax allows us to define, among other things, negation (`!condition`), conjunction (`condition1 && condition2`) and condition alternatives (`condition1 || condition2`).
* **Access to component values:** To retrieve current field values, use the function **`getValue("COMPONENT_ID")`**, where *COMPONENT\_ID* is the identifier of a field, session variable, or form component. [This is the recommended way to get a component value (other methods may cause performance issues). ](#user-content-fn-1)[^1]For example, calling `getValue("TextField1")` will return the current text entered in the text field with ID = TextField1.
* **Access to other attributes:** Besides value, components also have other properties that can be referenced. This is what the function **`getData("COMPONENT_ID", "ATTRIBUTE")`**&#x69;s for, returning the value of the given component attribute. For example `getData("Checkbox1", "visible")` will return information about the visibility of field **Checkbox1** (similarly to using `isVisible("Checkbox1")`). The list of available attributes for individual component types is shown in the component documentation and partly discussed in the next section.
* **Data types in conditions:** All values retrieved from fields are treated as text (strings) when the condition is evaluated. Therefore, for numeric or logical comparisons, you must convert data types yourself. You can use standard JavaScript functions such as `parseInt()` (conversion to integer) or `parseFloat()` (conversion to floating-point number). For boolean values, remember that the string `"true"`/`"false"` should be compared as a string or converted to a boolean type.
* **Constants:** In expressions, you can use string constants (in quotes), numeric constants (written directly), and logical constants (`true`/`false` without quotes).
* **Session variables in conditions:** If we want to use a session variable (global for the request) in a condition, we can reference it via `getValue("VARIABLE_NAME")`. In some cases (e.g. inside composite components), the variable name must be preceded by the character `@`. For example, the expression `getValue("@variable1")=="Y"` will check whether the session variable `zmienna1` has the value "Y". Note: predefined system variables (if any) may not require this prefix. However, it is recommended to use `@` before your own variable names in complex contexts to avoid ambiguity.
* **Complex conditions and dependencies:** You can build complex expressions by combining multiple comparisons with logical operators. For example, the expression `getValue("Field1") != "" && parseInt(getValue("Field2")) > 100.` The expression will return `true` only if *Field1* is not empty **and at the same time** the numeric value *of Field2* is greater than 100. When defining conditions that depend on the values of other fields, **remember to define listening** – more on this later (the [**ListeningOn**](#user-content-fn-2)[^2]).

## Component attributes

Each form component has a set of standard attributes describing its state. The most important common attributes are:

* **`value`** – the current *internal* value of the component (e.g. text entered in a field, a checkbox selection, a selected list option).
* **`displayValue`** – the value *displayed* to the user. It often matches `value`, but for some fields it may differ (e.g. in a Combobox `value` is the code/ID of the selected option, and `displayValue` is the label text).
* **`visible`** – information about the component's visibility (`"true"` or `"false"`). In conditions, you can also use the function `isVisible("ID")` which serves a similar role.
* **`enabled`** – information about the activity (editability) of the component, takes the value `"true"` when the field is active or `"false"` when it is disabled (non-editable). This attribute determines whether the user can interact with the given field.

Other attributes may be specific to a component type. For example, a dropdown list component (Combobox) exposes attributes **`label`** (selected option text), **`description`** (additional description) or **`size`** (number of available options). The *Statements* component has a collection of items `statementsItemControl` representing individual declarations. A detailed list of attributes is available in the documentation for each component type.

|                                                    |                                                                                                                                     |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Text field                                         | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Text area                                          | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Date                                               | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Date range                                         | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Plus minus                                         | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Formatted content (and collapsible)                | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Field for selecting a value from a list (Combobox) | <p>label - text of the selected value<br>description - description of the selected value<br>size - length of the list of values</p> |
| Account selection                                  | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Checkbox                                           | <p>moreInfoButtonClicked<br>value<br>displayValue<br>visible</p>                                                                    |
| Radio                                              | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Radio group                                        | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Tile group                                         | <p>content - returns displayValue<br>value<br>displayValue<br>visible</p>                                                           |
| Tile                                               | visible                                                                                                                             |
| Statements                                         | <p>statementsItemControl<br>value<br>displayValue<br>visible</p>                                                                    |
| Slider                                             | <p>sliderValue<br>value - (defaultValue)<br>displayValue<br>visible</p>                                                             |
| Step Slider                                        | <p>sliderValue - value<br>value - (defaultValue)<br>displayValue<br>visible</p>                                                     |
| Double range slider                                | <p>value<br>displayValue<br>visible</p>                                                                                             |
| A section                                          | folded                                                                                                                              |
| Checkbox section                                   | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Repeatable section                                 | folded                                                                                                                              |
| Contextual help                                    | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Product selection                                  | <p>variantId<br>productId<br>value<br>displayValue<br>visible</p>                                                                   |
| Picture card                                       | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Attachments                                        | <p>totalFilesSize<br>fileNames<br>externalIds<br>value<br>displayValue<br>visible</p>                                               |
| Data confirmation component                        | <p>wasEdited<br>value<br>displayValue<br>visible</p>                                                                                |
| QR code scanner                                    | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Map                                                | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Specialized component                              | <p>value<br>displayValue<br>visible</p>                                                                                             |
| Frontend component                                 | <p>value<br>displayValue<br>visible</p>                                                                                             |

**Referencing attributes in conditions:** As mentioned, `getData(id, "attribute")`is used to read an attribute. However, in practice most conditions simply check the field value (`value`) or its visibility/enabled state. For convenience, the Eximee platform provides dedicated API methods:

* **`getValue("ID")`** – returns `value` the component with the given ID (most commonly used).
* **`isVisible("ID")`** – returns information about the component's visibility (string `"true"`/`"false"`).

*(Some special components have additional methods, e.g. for handling declaration groups – described later.)*

> *Example:* If the text field *AdresEmail* has the identifier `GesTextField5`, then:
>
> * `getValue("GesTextField5")` will return the entered email address,
> * `isVisible("GesTextField5")` will return `"true"` if the field is visible or `"false"` if it has been hidden.

**Special attributes – Declarations component:** For components of type *Statements* (list of consents/approvals), functions are available to check whether a specific declaration has been selected. The method **`getStatementValue("COMPONENT_ID", "DECLARATION_MID")`** returns the value of the given declaration (consent) on this component. In newer versions, this function may be available as `getStatementItem`. Usage is as follows: e.g. `getStatementValue("Consents1", "newsletter") == "true"` will return `true`, if in the component with ID *Consents1,* the declaration with identifier (MID) *newsletter* is accepted by the user.

## Advanced condition editor

Eximee Designer provides **an advanced condition editor**, which makes it easier to create, edit, and verify conditional expressions. This editor includes the following features:

* **Syntax highlighting:** the syntax of JavaScript expressions is highlighted with colors, which increases the readability of complex conditions.
* **Auto-suggestions:** while editing a condition, suggestions are shown for available variables and form fields, as well as Eximee API elements and commonly used JS methods.
* **Prefix handling "`js:"`:** there is no need to manually enter the prefix `"js:"` before the condition – the editor omits it in the view and automatically adds it to the source code when saving the condition. This way, the user enters only the actual expression, and the platform ensures the correct format.

**Where the condition editor is used:** The advanced editor is used in component property fields such as: **the visibility condition**, **activity (edit) condition** and **requiredness condition**. These three properties of each form component use the described editor and allow entering a formula that determines, respectively, whether the component is visible, active (enabled), and whether it is required to be filled in.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FmETG15vbI4zoi572JY0P%2Fimage.png?alt=media&#x26;token=bdde05b7-a52d-4489-aa26-f2d5bd98ff56" alt=""><figcaption></figcaption></figure>

**Syntax hints in the editor:** In condition editing mode, you can use hints by pressing the keys **Ctrl + Space**. This will display a list of available elements to use. Among the suggestions are, among others:

* *Standard JavaScript functions and properties:* `parseInt()`, `parseFloat()`, property `.length` (text length) or `size` (list size), as well as other commonly used constructs (e.g. the keyword `empty` for checking empty values).
* *Eximee API:* platform-provided functions such as `getValue()`, `getData()`, `isVisible()` or `getStatementValue()`will appear in the suggestion list, reminding you that they are available.
* *Field and variable identifiers:* the editor automatically suggests **component MIDs** available in the given form (along with their technical ID in parentheses) and the names of session variables used in the request. This allows you to quickly insert a reference to a specific field without having to remember its exact identifier.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2F52zBTvRCbwWxpmXqnAXm%2Fimage.png?alt=media&#x26;token=416100e1-2783-4b42-b07a-cec84916dabe" alt=""><figcaption></figcaption></figure>

> **Tip:** If there are many fields, to quickly find the suggestion for a specific component in the list, start typing its name (MID) – the list will be filtered. Suggestions help avoid typos in IDs and let you discover available functions.

## Examples of conditional expressions

Below are a few example conditional expressions along with descriptions of how they work. Each example shows a piece of code used in the condition definition and an explanation:

* ```js
  parseInt(getValue("GesTextField3")) > 5
  ```

  – integer comparison: checks whether the numeric value entered in the text field `GesTextField3` is greater than 5.
* ```js
  parseFloat(getValue("GesTextField5")) < 200.001
  ```

  – floating-point comparison: checks whether the value from the text field `GesTextField5` (e.g. an amount or a number with decimal places) is less than 200.001.
* ```js
  getValue("GesCheckbox1") == "true"
  ```

  – logical comparison (equality): checks whether the field of type *Checkbox* with ID `GesCheckbox1` is checked (has the value `"true"`).
* ```js
  getValue("GesCheckbox1") != "true"
  ```

  – logical comparison (inequality): checks whether the same checkbox **no** is checked (i.e. the value is not `"true"` – in practice `"false"` or no value).
* ```js
  getValue("GesRadioGroup1") == "audi"
  ```

  – text comparison: checks whether the option with value `GesRadioGroup1` was selected in the Radio button group with ID `"audi"` (e.g. one of the car brands).
* ```js
  !!getValue("nazwiskoZew")
  ```

  – double negation: checks whether a given value is not empty. Two exclamation marks convert the value to boolean – the expression will return `true`if the variable or field `nazwiskoZew` has a non-empty value (e.g. the user entered a surname), and `false` otherwise.
* ```js
  !getValue("nazwiskoZew")
  ```

  – negation: checks whether the value is empty. It will return `true`if the field/variable `nazwiskoZew` **has no value** (e.g. the user entered nothing), which in JavaScript is equivalent to the value *falsy* (e.g. an empty string `""`).
* ```js
  getStatementItem("GesStatementPopup1", "oswiadczenie1") == "true"
  ```

  – condition for a component of type *Statements*: checks whether in the component with ID `GesStatementPopup1` the declaration with identifier (MID) `oswiadczenie1` is selected (i.e. whether the user accepted this declaration).
* ```js
  getStatementItem("@GesStatementFlat5", "zdrowotne") == "false"
  ```

  – a similar condition for *Statements* inside a composite component: checks whether the declaration `zdrowotne` in the component with ID `GesStatementFlat5` (embedded in a composite component, hence the prefix `@`) **has not been** selected by the user.
* ```js
  !!!(getValue("@GesTextField13") || getValue("@GesTextField8"))
  ```

  – example of a requiredness condition: the triple negation before the expression in parentheses checks whether *both* text fields `GesTextField13` and `GesTextField8` are empty. Inside the parentheses, the operator `||` returns the first non-empty value (or empty if both values are empty). Applying `!` reverses the result, and `!!` converts it to boolean. The effect of the whole expression is `true` only if **both fields are empty** (then, for example, another field becomes required). When either field has a value, the expression will return `false` (i.e. the requiredness condition is not met, so for example the given field does not need to be required).
* ```js
  getValue("@GesCombobox1") != 2 && getValue("@GesCombobox1") > 0
  ```

  – a complex condition for a dropdown list (Combobox): checks two things at once – whether the value selected in the Combobox field `GesCombobox1` **is not equal to 2** and whether it is **greater than 0**. Such a condition could be used, for example, to verify a selection other than the default one (assuming that the value `0` means no selection, and `2` is some excluded option).
* ```js
  isVisible("@GesTextField1") == "true"
  ```

  – visibility state check: the condition will return `true`, if the component with ID `GesTextField1` is currently visible (e.g. another condition did not hide it). This can be used to make behavior depend on whether another field is on screen.
* ```js
  getValue("GesTextField5").length == 10
  ```

  – text length check: the condition returns `true`, if exactly 10 characters have been entered in the text field `GesTextField5` . This can be used, for example, to validate a format (checking whether a number has the required length).

*(In the above examples, system-generated sample identifiers were used, such as **GesTextField5**. In a real project, it is recommended to give fields clear business identifiers (MID), which makes it easier to reference them later in conditions)*

### Conditional expressions in composite and business components

* Inside a composite/business component, to clearly indicate a variable/field from that component, prefix the name with the character `@`:
  * `getValue("@variableName")`
  * Example: `getValue("@defaultCurrency") == "USD"`.
  * Why? during condition evaluation `@` expands to the component identifier, e.g. `getValue("@variableName")` → `getValue("GesComplexComponent1.variableName")`, which eliminates name collisions with the main form on which the component was placed.
* When there is a name collision (the same variable/field in the main request and in the component) or you want to be precise — use `@` even if the condition works without it.
* Good practice: in composite/business components, always prefix variable/field names with the character `@` in conditional expressions, unless you intentionally want to reference a variable/field from the main form - then omit `@`
* Note: system predefined variables are placed on the main form, so we refer to them directly by name, omitting the character `@`.

Examples:

* Main form: `getValue("defaultCurrency") == "USD"`.
* Inside the component (specifically to the variable from that component): `getValue("@defaultCurrency") == "USD"`.

## FAQ – Most common questions

**How do I set a component to display conditionally (e.g. after checking a checkbox)?**\
You need to use the property **Visibility condition (visibleCondition)** available in the component properties panel. In the condition field, enter an expression that should return `true` when the component is to be visible. For example: if the field *AdditionalSection* should appear after checking the checkbox *ShowSections (id=GesCheckbox7)*, then set the visibility condition: `getValue("GesCheckbox7") == "true"`. When the user checks the checkbox, the condition will be satisfied and *AdditionalSection* will become visible.

**The condition doesn't refresh when another field changes – what am I doing wrong?**\
Most likely the **listening**setting is missing. For a component to react to changes in the value of another field used in the expression, you need to set its **ListeningOn** attribute **Interactions** (Listening) pointing to that field. In other words, the component with the condition must "listen" to the component on which the condition depends. In Eximee Designer, you do this in the component properties section – add the dependent field identifier to the Listening list. After listening is set correctly, changing the value of one field will automatically cause the condition in the other field to be re-evaluated.

**How can I check in a condition whether a field is empty or filled?**\
You can do this in several ways. The simplest is to use the fact that an empty string in JavaScript is a *falsy* (falsy) value. For example: the expression `!getValue("FieldX")` will return `true`, when *FieldX* is empty (negating an empty string gives true). Conversely, the expression `!!getValue("FieldX")` will return `true`, only if *FieldX* has some value (double negation converts the value to boolean while preserving its "truthiness"). Alternatively, you can compare directly to an empty string: `getValue("FieldX") == ""` (empty) or `getValue("FieldX") != ""` (filled).

**Do I need to add the prefix `js:`?**\
No. In the Eximee Designer editor, you enter only the condition expression itself, without any prefixes. The prefix `"js:"` is added automatically in the source code and is used internally to indicate that the condition should be interpreted as a JavaScript script. If you inspect the request XML configuration, you will see `condition="js:...your_expression..."`, but in the Designer interface you do not need to (and should not) type it yourself.

**How do I define a condition that is always satisfied (always true)?**\
If we want a given action/condition to be *always* true (e.g. so that an element is always visible or an action is always executed), we can enter a true constant as the expression. In practice, it is enough to enter the value **`true`**. The editor will add the appropriate prefix and the condition will be treated as always satisfied. Alternatively, you can enter **`js:true`** in the raw configuration – the effect will be the same. Likewise, an always-false condition can be obtained by entering `false` (which will cause, for example, a given component to never be visible on its own).

**Can I use any JavaScript functions in conditions?**\
Basic JavaScript functions and operators are supported, especially those suggested by the editor (such as `parseInt`, `parseFloat`, logical operators, etc.). However, remember that the condition is executed in the user's browser context, so it should not contain calls that may be incomprehensible or unavailable. A good practice is to limit yourself to simple operations and use the API provided by the Eximee platform (e.g. `getValue`, `getData`, etc.) for consistency and performance. Direct references to DOM elements or global variables are not supported and may cause errors. If you need complex logic, consider placing it in validator code or a service.

[^1]: I would probably not point readers to other methods, especially since they may cause performance issues.

[^2]: would be useful as a link here
