Skip to main content

HCMS Schema - Asset Template

Describes a special mechanism to provide initial values of new assets.

Normally, asset for new entity is created as empty, with only some required attributes

  • asset type (always contains value from schema)
  • domains (root. or the value configured in Headless CMS configuration xml)
  • application (default)
  • name (untitled)

Default values for new entities can (and should) be implemented as part of business logic or by webhooks, but these mechanisms have one disadvantage: they can only set features (relations, etc) that are part of the entity mapping.

In some special cases, new assets have to contain some special feature and/or relations that are not part of the entity mapping.
This typically happens when the Headless CMS application is integrated with some other, already existing code. For these cases, it is possible to specify complex initial values with their own, special schema.

Special property cs:template must be JSON object with two properties:
schema: Full mapping schema, completely independent of the entity mapping schema itself.
defaultValues: JSON object value that conforms to the special schema.

When creating new entity with cs:template, full process follows these steps:

  1. New asset is created, with pre-filled default values as usual.
  2. JSON object from cs:template/defaultValues is imported by using the cs:template/schema
  3. The value provided from caller is imported by using the real entity schema.

Example:
following snipped ensures that all new assets of this entity are in provided domain (different from all other asset) without exposing it to all readers.

JSON
{
  "cs:template": {
    "schema": {
      "type": "object",
      "properties": {
        "domain": {
          "cs:feature.key": "censhare:asset.domain",
          "type": "string"
        }
      }
    },
    "defaultValues": {
      "domain": "root.people."
    }
  }
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.