Aspects

An aspect is a mechanism for extending the functionality of a data type without modifying the type itself. An aspect adds extra attributes, a configuration form, and associated behavior to entities, while leaving the data type unchanged.

The same aspect can be attached to multiple data types, enabling logic reuse without duplication. An aspect can be added to a type explicitly — via the Aspects tab in the type settings — or automatically, depending on the configuration.

Aspect attributes are accessible via a prefix in the format {prefix}:{attribute.id}, which allows them to be uniquely identified in forms, journals, action configurations, and record mutations.

Citeck provides built-in system aspects for common tasks: time tracking, document relationship management, barcode generation, event history configuration, data import, and activity processing.

The aspects journal is available at: v2/journals?journalId=ecos-aspects&viewMode=table&ws=admin$workspace

Aspect Model

id: String // Идентификатор аспекта
name: MLText // Имя аспекта (справочная информация)
prefix: String // Префикс аспекта. Будет добавляться перед идентификатором каждого атрибута, которые описаны в attributes и systemAttributes
configFormRef: EntityRef // Ссылка на форму, которую следует использовать для редактирования конфигурации аспекта в типе ECOS
attributes: List<AttributeDef> // Атрибуты аспекта, которые будут добавлены к сущностям с данным аспектом
systemAttributes: List<AttributeDef> // Системные атрибуты аспекта, которые будут добавлены к сущностям с данным аспектом. Системные атрибуты могут быть изменены только под пользователем system.

The type configuration includes an aspects field that contains a list of aspects and their configuration:

TypeDef
...
aspects: List<TypeAspectDef>
...

TypeAspectDef
ref: EntityRef // ссылка на аспект
config: ObjectData // конфигурация аспекта

API

Check Whether an Entity Has an Aspect

await Records.get('emodel/some-id@local-id').load('_aspects._has.aspectToTest?bool!')

where,

emodel/some-id@local-id - the identifier of the entity whose aspect presence we want to check

aspectToTest - the identifier of the aspect whose presence we are checking

Get Aspect Configuration from an Entity

await Records.get('emodel/some-id@local-id').load('_type.aspectById.you-aspect-id.config')

Add an Aspect to an Entity

Note

An aspect is also added automatically when an attribute belonging to that aspect is set on the entity

var rec = Records.get('emodel/some-id@local-id');
rec.att('att_add__aspects', 'emodel/aspect@aspectToAdd');
await rec.save();

where,

emodel/some-id@local-id - the identifier of the entity to which we want to add the aspect

aspectToAdd - the identifier of the aspect being added

Remove an Aspect

var rec = Records.get('emodel/some-id@local-id');
rec.att('att_rem__aspects', 'emodel/aspect@aspectToRemove');
await rec.save();

where,

emodel/some-id@local-id - the identifier of the entity from which we want to remove the aspect

aspectToRemove - the identifier of the aspect being removed.

User guide for working with aspects