Skip to content

WriteTemplateExtension

Adds, replaces and removes extension Properties for the children of one parent Item, then persists them.

Changes accumulate on this instance and are stored only when update resolves. Property values that children store under an extension key are readable and writable once the extension is persisted.

Add a Property and persist it

const extension = await directory.extensions(ctx.apps.employeeProfile.templates.employee);
extension.add('isRemote', 'boolean', { label: 'Remote' });
await extension.update();

readonly definition: TemplateDefinition

The Template definition with properties replaced by the extended Property set.

ReadTemplateExtension.definition


readonly prn: string

The PRN of the extended Template.

ReadTemplateExtension.prn


readonly properties: Record<string, PropertyDefinition>

Template Properties and extension Properties together, keyed by Property key; extensions carry isExtension: true.

ReadTemplateExtension.properties

add(key, type, options?): PropertyBuilder

Starts a new extension Property and returns its builder for further configuration.

string

The Property key; it must be a valid key.

PrimitiveDataType | TemporalDataType

The data type of the new Property. boolean, date and single-select are accepted.

PropertyDefinitionOptions<PropertyDefinitionType>

Label and format for the Property.

PropertyBuilder

A PropertyBuilder, or a SelectPropertyBuilder for single-select so that options can be added.

when type is not one of the accepted types.

add(key, type, options?): SelectPropertyBuilder

Starts a new select extension Property and returns a builder that accepts its options.

string

The Property key; it must be a valid key.

SelectDataType

The select data type; single-select is accepted.

PropertyDefinitionOptions<PropertyDefinitionType>

Label and format for the Property.

SelectPropertyBuilder

when type is not an accepted type.

add(key, type, options?): unknown

Starts a new extension Property of any data type, returning the builder matching the type.

string

The Property key; it must be a valid key.

PropertyDefinitionType

The data type; boolean, date and single-select are accepted.

PropertyDefinitionOptions<PropertyDefinitionType>

Label and format for the Property.

unknown

when type is not an accepted type.


remove(key): this

Removes a previously persisted extension Property.

string

The key of the extension Property to remove.

this


set(definition): this

Adds or replaces an extension Property from a complete definition, superseding any builder started with add for the same key.

PropertyDefinition

The Property definition to store; it must be valid and carry a valid key.

this

when the definition is not a valid Property definition.


update(): Promise<WriteTemplateExtension>

Persists the accumulated changes on the parent Item.

Promise<WriteTemplateExtension>

A fresh extension reflecting the stored state.