> ## Documentation Index
> Fetch the complete documentation index at: https://zenskar.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Concepts: How custom attributes work

> This document explains custom attributes, the fields that you define on customers, contracts, and products to hold details that billable metrics and document templates can use.

## Custom attributes

> [accordion] Walkthroughs
>
> You can start with a walkthrough instead of reading this document first. A walkthrough is the practical extension of the concepts in this document. It puts them into practice through one example with concrete values. Each part of the walkthrough explains the concepts that its steps apply and links to the sections that cover them.
>
> | Walkthrough | What it shows |
> | - | - |
> | [End-to-end walkthrough: How custom attributes work](https://zenskar.com/docs/20260301/zenskar-modules/settings/custom-attributes/walkthroughs.md) | This example-based document shows how to add a required customer attribute and follow its value from a customer to new contracts and invoices. |

> [accordion] Map of concepts
>
> | Concept | What it is | What it is used for |
> | - | - | - |
> | [Custom attribute](#custom-attributes-details-that-you-add-to-records) | A field that an organization adds to customers, contracts, or products to record details that their fixed fields do not hold | Each customer, contract, or product has its own value for a custom attribute. |
> | [Custom attribute key](#custom-attribute-keys-how-a-custom-attribute-is-identified) | The identifier of a custom attribute | Zenskar finds a custom attribute and its values by its custom attribute key. |
> | [Custom attribute type](#custom-attribute-types-what-a-value-can-hold) | The kind of value that a custom attribute holds | The custom attribute type of a custom attribute decides what each of its values holds. |
> | [Copied value](#copied-values-how-new-records-receive-values) | The value of a custom attribute that a new record receives from the customer or the contract that it belongs to | If a customer attribute or a contract attribute copies to new records, each new contract or invoice of its record receives a copied value. |

> [accordion] Related modules
>
> Custom attributes uses the following modules:
>
> | Module | Details |
> | - | - |
> | [Business entity](https://zenskar.com/docs/20260301/zenskar-modules/settings/business-entity.md) | A custom attribute can apply to one business entity. |
>
> The following modules use Custom attributes:
>
> | Module | Details |
> | - | - |
> | [Customers](https://zenskar.com/docs/20260301/zenskar-modules/customers/concepts.md#customers-who-you-bill) | A customer can have a value for each customer attribute. |
> | [Contracts](https://zenskar.com/docs/20260301/zenskar-modules/contracts/concepts/contracts.md) | A contract can have a value for each contract attribute. A contract can receive a copied value of a customer attribute. |
> | [Products](https://zenskar.com/docs/20260301/zenskar-modules/products/concepts/products.md#products-what-you-sell) | A product can have a value for each product attribute. |
> | [Billable metrics](https://zenskar.com/docs/20260301/zenskar-modules/usage/concepts/billable-metrics.md#zenskar-sql-variables-values-that-zenskar-fills-in) | A billable metric can match usage to a customer by a customer attribute. A query in the SQL builder can use the values of custom attributes as Zenskar SQL variables. |
> | [Communications](https://zenskar.com/docs/20260301/zenskar-modules/more/communications/templating-guide.md) | A template can use a custom attribute key. |

## Custom attributes: details that you add to records

A **custom attribute** is a field that an [organization](https://zenskar.com/docs/20260301/zenskar-modules/settings/glossary.md#organization) adds to customers, [contracts](https://zenskar.com/docs/20260301/zenskar-modules/contracts/glossary.md#contract), or [products](https://zenskar.com/docs/20260301/zenskar-modules/products/glossary.md#product) to record details that their fixed fields do not hold.

![Conceptual diagram of a custom attribute. A custom attribute has a name, a custom attribute key, a custom attribute type, a list of options, a default value, and whether it is required. A customer attribute or a contract attribute can also copy to new records. Its custom attribute type is text, whole number, decimal number, checkbox, dropdown, multi-select, or array. A product is a representative example of a record that has values of custom attributes. Other modules also use custom attributes.](https://assets.zenskar.com/20260301/custom-attributes-concepts-custom-attribute-structure-class-light.png)

This conceptual diagram shows what a custom attribute has, with a product as an example of a record that uses custom attributes.

Zenskar gives each customer, contract, and product a fixed set of fields. When a business needs to record more, such as the sales region of each customer, it adds a custom attribute.

An organization sets up a custom attribute once, and each customer, contract, or product then has its own value for it. The name and the [custom attribute key](#custom-attribute-keys-how-a-custom-attribute-is-identified) of a custom attribute are unique in the organization, across all kinds of records.

> [!NOTE]
>
> A custom attribute cannot be deleted.

A custom attribute belongs to one kind of record:

| Custom attribute | Record that it belongs to |
| - | - |
| Customer attribute | [Customer](https://zenskar.com/docs/20260301/zenskar-modules/customers/concepts.md#customers-who-you-bill) |
| Contract attribute | [Contract](https://zenskar.com/docs/20260301/zenskar-modules/contracts/glossary.md#contract) |
| Product attribute | [Product](https://zenskar.com/docs/20260301/zenskar-modules/products/glossary.md#product) |

The kind of record that a custom attribute belongs to cannot change after the custom attribute is created.

### Scope: which records a custom attribute applies to

A custom attribute has one of two scopes:

| Scope | Custom attributes |
| - | - |
| One [business entity](https://zenskar.com/docs/20260301/zenskar-modules/settings/glossary.md#business-entity) | Customer attribute, contract attribute |
| All business entities of the organization | Customer attribute, contract attribute, product attribute |

A custom attribute scoped to one business entity applies only to the records of that business entity. Changing the scope of a custom attribute does not change the values saved on records.

### Required values: what a record must have

A required custom attribute needs a value on every record, such as a sales region on every customer. It works as follows:

* Saving a record without a value writes the [default value](#default-values-what-a-new-record-starts-with).
* Without a default value, saving a record without a value fails.
* You cannot remove its value from a record of the kind that it belongs to.

Making a custom attribute required, or optional again, does not change the values already saved on records. A record that has no value follows these rules at its next save.

## Custom attribute keys: how a custom attribute is identified

A **custom attribute key** is the identifier of a custom attribute.

A custom attribute has a name and one custom attribute key:

| Property | Description | Example |
| - | - | - |
| Name | You recognize a custom attribute by its name. | `Sales region` |
| Custom attribute key | Zenskar finds a custom attribute and its values by the custom attribute key. | `sales_region` |

A custom attribute key cannot change after the custom attribute is created. The name can change at any time, without affecting the custom attribute key or anything that uses it.

## Custom attribute types: what a value can hold

A **custom attribute type** is the kind of value that a custom attribute holds.

A custom attribute type cannot change after the custom attribute is created. Each custom attribute has one of the following custom attribute types:

| Custom attribute type | What a value holds | Example value |
| - | - | - |
| Text | Any text | `Northern office` |
| Whole number | A number without decimals | `12` |
| Decimal number | A number that can have decimals | `12.5` |
| Checkbox | `Yes` or `No` | `Yes` |
| Dropdown | One option from a list that you set | `EMEA` |
| Multi-select | Any number of options from a list that you set | `EMEA`, `APAC` |
| Array | A list of text items | `gold`, `renewal` |

### Options: what a list value can be

The list types, dropdown and multi-select, use a list of options:

* A value must come from the list of options.
* A record keeps an option that was removed from the list.

### Default values: what a new record starts with

A default value must fit the custom attribute type, such as `EMEA` for a sales region. It works as follows:

* A new record without a value gets the default value of the custom attribute.
* Adding or changing a default value does not change existing records.

## Copied values: how new records receive values

A **copied value** is the value of a custom attribute that a new record receives from the customer or the contract that it belongs to.

| Custom attribute | New records that can receive a copied value |
| - | - |
| Customer attribute | Contracts and invoices of the customer. |
| Contract attribute | Invoices of the contract. |
| Product attribute | None. |

> [!NOTE]
>
> Copied values keep records auditable.

For example, Acme Corp is a customer with the customer attribute `Sales region`, which copies to new contracts and invoices of Acme Corp. The value of `Sales region` on Acme Corp starts as `APAC`.

| Event | Acme Corp | `Contract_1` | `Contract_2` | Invoice of `Contract_1` |
| - | - | - | - | - |
| 1. Your billing team creates `Contract_1`. | `APAC` | `APAC` (copied value) | | |
| 2. `Sales region` on Acme Corp changes to `Americas`. | `Americas` | `APAC` | | |
| 3. Your billing team creates `Contract_2`. | `Americas` | `APAC` | `Americas` (copied value) | |
| 4. Your billing team changes `Sales region` on `Contract_1` to `EMEA`. | `Americas` | `EMEA` | `Americas` | |
| 5. `Contract_1` creates an invoice. | `Americas` | `EMEA` | `Americas` | `EMEA` (copied value) |

### Behavior: how copied values work

* A new record receives a copied value once, when the record is created. `Contract_1` receives `APAC` when your billing team creates it.
* A copied value does not change when its source changes. When `Sales region` on Acme Corp changes to `Americas`, `Contract_1` keeps `APAC`. `Contract_2`, created after that change, receives `Americas`.
* Draft and upcoming invoices are an exception. When an [active contract](https://zenskar.com/docs/20260301/zenskar-modules/contracts/glossary.md#active-contract) changes, Zenskar rebuilds its draft and upcoming invoices. Each rebuilt invoice receives the copied value again. When `Sales region` on `Contract_1` changes to `EMEA`, each draft invoice of `Contract_1` receives `EMEA`. Other invoices keep their values.
* A change to a copied value does not change its source. When `Sales region` on `Contract_1` changes to `EMEA`, Acme Corp keeps `Americas`.
* A new record receives the copied value from the nearest record that has a value. The invoice receives `EMEA` from `Contract_1`. If `Contract_1` had no value, the invoice would receive `Americas` from Acme Corp.
* A value that uses an option removed from the list still copies. If `Americas` is removed from the list, a new contract of Acme Corp still receives `Americas`.
* Turning copying on or off affects only new records. If copying is turned off, `Contract_1` and `Contract_2` keep their values, but a new contract of Acme Corp receives no value.
* A record that can receive a copied value does not need a value, even when the custom attribute is required. If `Sales region` is required, Acme Corp needs a value, but `Contract_1` does not.
* A record that can receive a copied value does not get the default value. If `Sales region` has the default value `EMEA` and Acme Corp has no value, `Contract_1` has no value.

See [Restore a copied value on a new contract](https://zenskar.com/docs/20260301/zenskar-modules/settings/custom-attributes/how-to-guides.md#restore-a-copied-value-on-a-new-contract).

See [End-to-end walkthrough: How custom attributes work](https://zenskar.com/docs/20260301/zenskar-modules/settings/custom-attributes/walkthroughs.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.