Templates
Purpose
Templates define reusable metadata shapes for entities.
They help developers and authorized users create consistent objects without writing a new schema, form, and CRUD flow for every variation.
What A Template Controls
A template may define:
- entity type,
- property groups,
- property definitions,
- tag groups,
- default tags,
- default property values,
- allowed child entity types,
- allowed relationship types,
- display layout hints,
- validation rules.
Example: BACnet Controller Template
Template: BACnet Controller
Entity Type: asset
Property Groups:
├── Device
├── Network
└── BACnet
Tag Groups:
├── Vendor
├── Criticality
└── Commissioning Status
Allowed Relationships:
├── uses -> credential
├── connects_to -> asset
└── depends_on -> assetExample: Site Template
Template: Standard Customer Site
Entity Type: site
Property Groups:
├── Address
├── Network Access
└── Service Notes
Allowed Children:
├── building
├── asset
└── connection_methodTemplate Tables
Core table:
entity_templatesAssociations:
entity_template_property_groups
entity_template_tag_groups
entity_template_allowed_children
entity_template_allowed_relationshipsOnly implement the associations needed for current product scope.
Template Application
Creating an entity from a template should:
- validate template is active,
- validate actor has permission,
- create entity,
- create required default property values,
- attach default tags,
- apply optional defaults,
- emit audit event.
Template Versioning
Do not overbuild versioning immediately.
Recommended approach:
- Alpha: templates are mutable metadata.
- Later: add versioning if changes need historical reproducibility.
Versioning becomes important when:
- templates drive compliance,
- generated forms must reflect historical state,
- audits require knowing exactly which template version created an entity.
Template vs Entity Type
Entity type answers:
What kind of thing is this?Template answers:
What shape/configuration should this thing use?Example:
Entity Type: asset
Templates:
- BACnet Controller
- Head-End PC
- Network Switch
- UPS
- Modbus GatewayDeveloper Guidance
Use templates to reduce duplication.
Do not use templates to hide complex workflow logic.
For complex workflows, create application services and use templates only to provide metadata and defaults.
Frontend Guidance
Templates can drive:
- initial form sections,
- required fields,
- available tag groups,
- display order,
- default values.
The frontend should still use explicit application code for complex flows such as:
- credential creation,
- remote access setup,
- approval workflows,
- Simpro sync,
- asset commissioning flow.