Expressions
Expressions are small runtime code snippets that use standard JavaScript and TypeScript syntax to calculate values, control behavior, and interact with application data throughout Lowgile.
These expressions typically return a value that the application uses at runtime. They are commonly used to:
- Calculate values,
- Configure dynamic labels,
- Control visibility and behavior,
- Read and update runtime values, and
- Configure workflow and screen logic.
Where expressions are used
Section titled “Where expressions are used”Expressions are used throughout the platform, including:
- Screen bindings,
- Component labels and values,
- Visibility conditions,
- Workflow logic,
- Static entity expressions,
- Dynamic dropdown values,
- Computed values,
- Services and integrations, and
- AI-assisted extraction logic.
Expression contexts
Section titled “Expression contexts”Expressions execute within a runtime context that determines which objects and values are available.
Common expression contexts include:
| Context | Purpose |
|---|---|
screen | Accesses screen variables and screen state. |
item / itemIndex | Accesses the current loop item and loop index inside ForBlock components. |
This | Accesses application modules, entities, services, workflows, and static entities. |
Sys | Accesses Lowgile platform services and runtime functionality. |
Typical expression patterns
Section titled “Typical expression patterns”The following examples demonstrate common ways expressions are used throughout Lowgile to read runtime values, calculate results, control behavior, and generate dynamic content.
1. Access runtime data
Section titled “1. Access runtime data”Expressions commonly read values from runtime objects, variables, entities, workflows, screens, and platform objects.
For example:
screen.request.costCenterThis expression accesses the costCenter property from the request screen variable.
2. Configure dynamic labels
Section titled “2. Configure dynamic labels”Expressions can generate display values at runtime.
For example:
`${item.description} - ${item.quantity}`This expression combines multiple properties from the current item loop variable into a single display value.
3. Configure conditional logic
Section titled “3. Configure conditional logic”Expressions are frequently used to control visibility and runtime behavior.
For example:
screen.request.status === 'Approved'This expression returns a boolean value that can be used to show or hide components dynamically.
4. Perform calculations
Section titled “4. Perform calculations”Expressions can also calculate values at runtime.
For example:
screen.quantity * screen.unitPriceThis expression calculates a total value using two variables dynamically.
Expressions vs scripts
Section titled “Expressions vs scripts”Expressions and scripts serve different purposes.
1. Expressions
Section titled “1. Expressions”Expressions are usually small inline statements that return a value.
For example:
screen.request.status === 'Approved'This expression evaluates whether the request status is Approved and returns either true or false.
2. Scripts
Section titled “2. Scripts”Scripts are typically larger procedural blocks used to execute actions or runtime logic.
For example:
async function optionsList(): Promise<This.Materials.Entry[]> { const xls = await Sys.Xls.SimpleXls.fromFile('list-materials.xlsx', 'xlsx') return xls.parseToObjects({ sheetNameOrNumber: 'Materials' })}Test expressions in the console
Section titled “Test expressions in the console”The Lowgile console executes expressions within its own runtime context. Some runtime variables, such as item or itemIndex, are only available inside the components that provide them.