Working with calculated attributes
This functionality is available for Creatio 8.3.2 and later.
When developing front-end functionality in Creatio, developers often need to work with values that are calculated from other data. For example, display a value composed from multiple attributes, calculate a field value based on request results, or generate a value dynamically in response to user actions. Implementing this business logic required manually subscribing to attribute changes, tracking request execution, and explicitly updating these values. For complex business logic, this approach often resulted in code that was difficult to maintain and error-prone.
Since version 8.3.2, Creatio provides calculated attributes as a declarative way to define calculated values in the view model. A calculated attribute is an attribute whose value is computed automatically based on its configuration, rather than assigned directly. Calculated attributes are read-only. Calculated attributes allow you to define transformation logic and recalculation conditions without managing subscriptions or update logic manually.
Use calculated attributes when you need to:
- compute a value from one or more attributes
- compute a value based on request execution results
- keep related values synchronized automatically
- avoid manual subscriptions and update handlers
Creatio recalculates the value automatically when relevant dependencies change.
Calculated attributes are evaluated lazily and are recalculated only when their value is accessed. This helps avoid unnecessary computations and subscriptions while keeping the view model state consistent. Calculated attributes can also trigger additional logic when their value changes, while still remaining declarative.
Declarative calculation model
With calculated attributes, you define how a value is calculated through configuration rather than implementing update logic manually.
When defining a calculated attribute, you specify:
- Input view model attributes. When a specified input view model attribute changes, it triggers recalculation.
- Transformation logic
- Optional conditions that control recalculation
- Optional reactions to calculated value changes
Based on this configuration, Creatio determines when and how the value should be recalculated, without requiring explicit subscriptions or update handlers. This declarative model makes calculation logic easier to understand and reduces the risk of inconsistent state. Learn more about calculated attribute configuration properties: Calculated attribute configuration.
Dependency types
Calculated attributes can use different types of inputs depending on the scenario. Select how the calculated value is updated based on the dependency types listed in the table below.
Dependency type | Use cases | Calculation behavior | Subscription model |
|---|---|---|---|
Attribute-based dependencies | The calculated value is computed from other attributes in the view model. |
| Subscriptions to source attributes are created only when the calculated value is accessed (lazy). |
Request-based dependencies | The calculated value is computed from request execution results. |
| Subscriptions to requests are created immediately (eager) |
Attributes and requests are not mixed within the same dependency definition.
Processing attribute values
Calculated attributes support additional parameters that control how attribute values are produced and when they are recalculated. These parameters allow you to transform values, restrict recalculation, or react to specific events. Learn more about the properties used for processing attribute values: Calculated attribute configuration.
Select how to process attribute values based on the business goals listed in the table below.
Business goal | Property to use | Use cases |
|---|---|---|
Convert data into a calculated value with input sources | Define input sources using |
|
Convert data into a calculated value with request results | Define request-based sources using |
|
Convert data into a calculated value without sources | Define conversion logic using |
|
Control when recalculation should occur | Define a recalculation condition using |
|
Recalculate a value in response to specific events | Define recalculation events using |
|
Triggers extend dependency-based recalculation and do not replace source definitions. When used without explicit sources, recalculation remains lazy.