Static Entity
A Static Entity is a list of entries to choose from, such as order statuses or countries. You reach it as This.<StaticEntityName>: static members read the list, and an instance holds one selected entry.
Availability: Everywhere
How to reach it
Section titled “How to reach it”| Access path | What it is |
|---|---|
This.<StaticEntityName> | The Static Entity class: static members for the entry list, and the type of an instance that holds one selected entry. |
This.<StaticEntityName>.<EntryIdentifier> | A new instance with that entry selected. |
This.<StaticEntityName>.Id, This.<StaticEntityName>.Entry | The types of an entry’s id and of an entry. |
Static Entities are not grouped under a $ namespace.
Where the entries come from depends on the Static Entity’s source:
- Static: the entries defined in the editor. They are available as soon as the code loads.
- Dynamic (running on server and client): the editor’s entries plus those returned by the Static Entity’s code, which runs on each side.
- Dynamic (needs to run on server): the code runs on the server. On the client,
load()asks the server for its complete entry list. This request is always allowed: Access Control does not apply to it.
Lowgile loads dynamic entries when the code loads, and loads them again when the language changes. The caching settings of the Static Entity decide how long a loaded list stays valid.
Functions
Section titled “Functions”getEntryList()
Section titled “getEntryList()”static getEntryList(filters?: { entryProperty: string, values: any[] }[]): <StaticEntityName>.Entry[]getEntryList(filters?: { entryProperty: string, values: any[] }[]): <StaticEntityName>.Entry[]Returns the entries that are currently loaded, optionally filtered. The instance method returns the same as the static one.
| Parameter | Type | Description |
|---|---|---|
filters | { entryProperty: string, values: any[] }[] | Optional. An entry is returned only if, for every filter, the value of its property entryProperty is one of values. |
The list only contains dynamic entries once they are loaded. To be sure they are, call await This.<StaticEntityName>.load() first.
Returns: <StaticEntityName>.Entry[] · Availability: Everywhere
getEntryMap()
Section titled “getEntryMap()”static getEntryMap(): Record<<StaticEntityName>.Id, <StaticEntityName>.Entry>Returns the loaded entries as an object keyed by id.
Returns: Record<<StaticEntityName>.Id, <StaticEntityName>.Entry> · Availability: Everywhere
getEntry()
Section titled “getEntry()”static getEntry(id: <StaticEntityName>.Id): <StaticEntityName>.EntryReturns the loaded entry with the given id, or undefined if there is none.
| Parameter | Type | Description |
|---|---|---|
id | <StaticEntityName>.Id | The entry’s id. |
Returns: <StaticEntityName>.Entry · Availability: Everywhere
getChoices()
Section titled “getChoices()”static getChoices(labelColumn?: keyof <StaticEntityName>.Entry): Promise<Sys.Types.Choice[]>Returns the loaded entries as choices for a selection list, each with the entry’s id, a label and $isOther.
| Parameter | Type | Description |
|---|---|---|
labelColumn | keyof <StaticEntityName>.Entry | Optional. The entry property to use as the label. Default: '$displayValue', which uses the Static Entity’s display property. |
Returns: Promise<Sys.Types.Choice[]> · Availability: Everywhere
Note
getChoices() is declared as returning a Promise, but it runs synchronously and returns the array itself. await This.<StaticEntityName>.getChoices() works either way; calling .then() on the result fails.
load()
Section titled “load()”static load(forceReload?: boolean): Promise<void>Loads the entries, including dynamic ones, and waits until they are available. If a cached list is still valid, Lowgile uses it.
| Parameter | Type | Description |
|---|---|---|
forceReload | boolean | Optional. If true, loads the entries again even if a valid cached list exists. Default: false. |
Returns: Promise<void> · Availability: Everywhere
constructor()
Section titled “constructor()”constructor(idOrObject?: <StaticEntityName>.Id | <StaticEntityName> | null, otherValue?: string)Creates an instance with the entry of the given id selected, or with no entry selected.
| Parameter | Type | Description |
|---|---|---|
idOrObject | <StaticEntityName>.Id | <StaticEntityName> | null | Optional. The id of the entry to select, or an instance whose entry to select. Default: null, no entry selected. |
otherValue | string | Optional. The text for an “other” entry. Declared only if the Static Entity has “other” entries. |
Returns: a new <StaticEntityName> · Availability: Everywhere
set<EntryIdentifier>()
Section titled “set<EntryIdentifier>()”set<EntryIdentifier>(other?: string): voidSelects the entry. There is one method per entry, for example setOpen() for an entry with the identifier Open.
| Parameter | Type | Description |
|---|---|---|
other | string | Optional. The text for an “other” entry. Declared only for entries marked as “other”. |
Returns: void · Availability: Everywhere
$clone()
Section titled “$clone()”$clone(): <StaticEntityName>Returns a new instance with the same entry selected and, for an “other” entry, the same text.
Returns: <StaticEntityName> · Availability: Everywhere
Properties
Section titled “Properties”<EntryIdentifier>
Section titled “<EntryIdentifier>”static get <EntryIdentifier>(): <StaticEntityName>Returns a new instance with this entry selected, for example This.OrderStatus.Open. There is one static property per entry.
Type: <StaticEntityName> · Availability: Everywhere
static readonly ids: readonly <StaticEntityName>.Id[]readonly ids: readonly <StaticEntityName>.Id[]The ids of all loaded entries. Lowgile updates the list each time entries are loaded. The instance property returns the static one.
Type: readonly <StaticEntityName>.Id[] · Availability: Everywhere
id: <StaticEntityName>.IdThe id of the selected entry, or null if none is selected. Assign an id to select a different entry. For a Static Entity with the source Static, assigning an id that is not in the list throws an error.
Type: <StaticEntityName>.Id · Availability: Everywhere
$displayValue
Section titled “$displayValue”readonly $displayValue: stringThe value of the display property of the selected entry, as text.
Type: string · Availability: Everywhere
Note
For an “other” entry, $displayValue is undefined instead of the entered text. Read $otherValue for that text.
<propertyName>
Section titled “<propertyName>”get <propertyName>(): <type>The value of that property for the selected entry, or undefined if no entry is selected. There is one property per Static Entity property. A property whose type is another Static Entity returns an instance of that Static Entity.
Type: the property’s type · Availability: Everywhere
is<EntryIdentifier>
Section titled “is<EntryIdentifier>”get is<EntryIdentifier>(): booleantrue if this entry is selected, for example status.isOpen. There is one property per entry.
Type: boolean · Availability: Everywhere
$isOther
Section titled “$isOther”get $isOther(): booleantrue if the selected entry is an “other” entry. For Static Entities without “other” entries it is declared as false.
Type: boolean · Availability: Everywhere
$otherValue
Section titled “$otherValue”$otherValue: stringThe text entered for an “other” entry. Reading it returns '' when the selected entry is not an “other” entry. Declared only if the Static Entity has “other” entries.
Type: string · Availability: Everywhere
<StaticEntityName>.Id
Section titled “<StaticEntityName>.Id”type Id = <entry ids> | string | numberThe type of an entry’s id. For a Static Entity with the source Static, it is the union of the literal ids of its entries, for example 'open' | 'closed'. For a dynamic source it is string or number, depending on the type of the id property.
Availability: Everywhere
<StaticEntityName>.Entry
Section titled “<StaticEntityName>.Entry”interface Entry { id: <StaticEntityName>.Id <propertyName>: <type> $displayValue: string}One entry of the list, with a field per Static Entity property.
| Field | Type | Required | Description |
|---|---|---|---|
id | <StaticEntityName>.Id | Required | The entry’s id. |
<propertyName> | the property’s type | Required | The entry’s value for that property. For a property whose type is another Static Entity, an instance of that Static Entity. |
$displayValue | string | Required | The entry’s display text. |
Availability: Everywhere
Note
Entries defined in the editor have no $displayValue field at runtime, so it reads as undefined. Use the instance property $displayValue or getChoices() to get display texts.
Related
Section titled “Related”- Static Entities
- Entity API
- Sys.Types