If an Entity or Entities define the structure of your data, then instances are your data. |
In the runtime, an Entity takes shape in the form of an instance.
Take for example an application for managing a digital ticketing queue. The entity Customer has several Attributes, such as Name and BirthDate. There can be multiple customers in the queue, so there can also be multiple instances of the Customer entity.
The application only handles one queue at a time, so there is also an entity Queue, of which there is only one instance. This is called a "singleton".
Instances that are created at runtime (see below) are called dynamic instances. There are also static instances, these are created at design time in Encore. See Static instance.
Properties of instances are accessed by the name of the corresponding entity. Following the example above, Queue.Length could refer to the length of the queue and Customer.BirthDate refers to the birth date of one of the people in the queue.
Accessing an instance of a singleton entity is easy, as there is only one. However, for non-singleton (a.k.a. multiton) entities, how do we know which instance to access?
For this, we use the concept of active vs inactive. Only active instances can be accessed. Singletons are always active, but each multiton entity can only have one active instance at a time.
In your Logic (attribute value expressions, Decision tables, Business rules, Reusable Expressions, etc.), you always reason starting from "self" (in other words, the instance that you are setting a value for).
Based on this, you do not have control over which instances are active or inactive. You can refer to:
Within Flows, it is possible to control which instances are active in several ways:
You can also refer to:
Within a Page, it is possible to control which instances are active in several ways:
You can also refer to:
The two ways to refer to a static instance in a page or a container is through the use of a REPEAT expression, or a relation.
Several Service calls can be used to manage instances: