Configuring a Calculated Attribute with a Formula
Table of Contents
Use Case
The CMW Platform can calculate an attribute value on the fly (without storing it in the database) using a formula, N3 expression, DMN table, or another attribute.
In this article, we will configure the automatic client assignment for the currently logged-in user.
Prerequisites
In our example, we have a database of clients, company managers, and requests. A client is attached to each manager. So, we can automatically assign a client when the manager creates a request.
To proceed with the example, create the templates and attributes as shown in the table below:
Record template system name | Attribute system name | Attribute type | Description |
---|---|---|---|
Request | ClientForCurrentUser | Record |
The ClientForCurrentUser attribute is linked to the Clients template and calculated based on the data stored in the Contact_persons template. |
Contact_persons | Client | Record | The Client attribute is linked to the Clients template. |
Manager | Account | The Manager attribute stores the manager account ID. | |
Clients | Name | Text | The Clients template contains the client records. The Name attribute stores the client name. |
Instructions
- In the Request template, open the ClientForCurrentUser attribute.
- Check the Calculate using an expression box
- In the Calculated value field, enter the formula:
from a in db->Contact_persons where EQUALS(a->Manager,USER()) select a->Client->name
- Click Save to save the attribute.
Formula Syntax
Element | Description |
---|---|
from a in db->Contact_persons |
|
where EQUALS(a>Manager,USER()) |
|
select a->Client->Name |
|