Key and Label Scripts
Every entity has a key — its unique, readable identifier within its type — and a label, the name shown in headers, tables and the graph. Both can be computed by a Lua script on the entity type:
| Script | Computes | Example |
|---|---|---|
| Key Script | the key of each entity | A customer number used as key |
| Label Script | the display name of each entity | Julius-Hatry-Str. 1 for an Address (street and house number) |
Without a label script, the key is shown as the label. The language reference with more examples is in Lua Scripting.
Edit a Script
- Open the entity type, for example Address, on the tab Data Sheet.
- The fields Key Script and Label Script show the first line of the script; hover over it to see the whole script.
- Click next to the field. The dialog Script editor opens in the middle of the screen:
- Syntax highlighting for Lua (Language is always Lua).
- Autocomplete for
self.properties.*andself.relationships.*. - The AI Low Code Generator next to it: ask questions about the script in the field Ask about this script…. Code blocks in its answers can be taken over into the editor with Apply.
- Write the script and close the editor with ✕. The script is saved when the editor closes.
The script editor for the label script of Address
To remove a script, hover over the field and click Clear script. The script is cleared and saved immediately.
Example label script for an address, assuming its properties are named street and house_number:
return self.properties.street .. " " .. self.properties.house_number
There is no way to try a script on an entity in the editor. Test it by creating or editing an entity of the type.
When Scripts Take Effect
- The key is computed again with every commit of an entity. If a value used in the key changes, the entity gets a new key; the old key keeps pointing to the earlier commit.
- A changed script creates a commit of the entity type. New entities use it at once; existing entities use the script of the type commit they are bound to (see Model Changes and Existing Data).
Virtual Properties
A virtual property is computed by a script instead of being entered, for example a full address line from street, postcode and city. Add it on the tab Virtual Properties of the entity type with Link existing, like a normal property. The relationship properties are:
| Field | Notes |
|---|---|
| position, name, label, description | As for normal properties. |
| script | Required. Lua script that returns the value. |
| dynamic | Whether the value is computed dynamically. |
Virtual properties are read-only everywhere. They are computed when the entity is saved — if a related entity changes later, the value is not updated until the entity itself is saved again.