Custom fields

On this page

Per-project fields on tasks, in thirteen types, that can be filtered, sorted, displayed, required on workflow transitions, used by automation and asked for in forms.

Design document and history: Custom fields design. API conventions: API reference. Module index: Modules.

Overview #

Upstream tasks have a fixed set of properties. Teams that track budgets, severities, customers or ratings end up encoding them in titles or labels. Custom fields let a project admin define typed fields for the tasks of one project, and let everyone with write access to a task fill them in. Because values are stored in typed columns, they can be filtered and sorted in SQL, like built-in fields, in task lists, views, saved filters, reports and automation conditions.

Audience: project admins define fields; project members fill and read them; operators need to know the limits (below).

Concepts #

  • Field definition. Belongs to a project: title, description, type, a required flag, a type-specific config, a position, and (for select types) options. The required flag is used by workflow transitions (a transition can require a field), not enforced on every save.
  • Field value. Belongs to a task and a field. Single-value types have at most one row per (task, field); multi_select and user have one row per selected option or user.
  • Types. text, long_text, number, currency, date, checkbox, select, multi_select, user, url, email, rating, progress. The type cannot be changed after creation (error 20003).
  • Config keys by type: min, max (number, currency), precision (0 to 10, number and currency), currency (ISO 4217 code of at most three characters, currency), max_rating (1 to 10, default 5, rating).
  • Validation on write. Number and currency respect min and max; rating is an integer from 1 to max_rating; progress is 0 to 100; url and email are format-checked; select and multi select option ids must belong to the field; user ids must have read access to the task's project. Failures are 20005 (invalid value) or 20004 (unknown option).
  • JSON shape of a value depends on the type: string (text, long_text, url, email), number (number, currency, rating, progress), RFC 3339 string (date), boolean (checkbox), option id (select), array of option ids (multi_select), array of user ids (user). Sending null, or an empty array for multi_select and user, clears the value.
  • Field references in other documents (filters, workflow required fields, automation conditions and actions, form targets, report dimensions) are written cf_<id>.

Data model #

Diagram, shown as its Mermaid source. This site has no scripts, so it cannot draw it. View the rendered diagram on GitHub.
erDiagram
    projects ||--o{ custom_fields : "has"
    custom_fields ||--o{ custom_field_options : "has"
    custom_fields ||--o{ task_custom_field_values : "values of"
    tasks ||--o{ task_custom_field_values : "has"
    custom_fields {
        bigint id PK
        bigint project_id
        string title
        string type
        bool required
        json config
        double position
        bigint created_by_id
    }
    custom_field_options {
        bigint id PK
        bigint custom_field_id
        string title
        string color
        double position
    }
    task_custom_field_values {
        bigint id PK
        bigint task_id
        bigint custom_field_id
        text value_text
        double value_number
        datetime value_date
        bool value_bool
        bigint option_id
        bigint user_id
    }

Tables are created by pkg/migration/20261122120000.go. custom_fields.project_id, custom_field_options.custom_field_id, and task_custom_field_values.task_id, custom_field_id, option_id, user_id are indexed. Values are typed columns (not one JSON blob) so that filters and sorts run in SQL: text types use value_text, number, currency, rating and progress use value_number, date uses value_date, checkbox uses value_bool, select and multi select use option_id, user uses user_id.

Lifecycle: deleting a field deletes its options and values; deleting a task or purging a project deletes the values and definitions that belong to it (values are removed when a task is purged, not when it is moved to the trash); duplicating a project copies definitions and the values of the copied tasks with remapped ids; duplicating a task inside the same project copies its values; moving a task to another project (single or bulk) deletes its values for fields of the old project and keeps values of fields that exist in the new one.

Permissions #

ActionNeeds
Read definitionsread on the project
Create, update, delete a definitionadmin on the project
Read values of a taskread on the task
Set or clear a valuewrite on the task, and a field that belongs to the task's project

Link shares follow the share's permission for values and can never change definitions. An unknown field id, a field of a project the caller cannot read and a malformed identifier in a filter all answer the same 400 (4016), so field ids of other projects cannot be probed. Permission methods are in pkg/models/custom_fields_permissions.go.

API #

All routes are on /api/v2. Conventions (envelopes, ETags, errors) are in API reference. A PATCH is also available for a field definition.

MethodPathOperation IDPermissionDescription
GET/projects/{project}/custom-fieldscustom-fields-listread on projectList the custom fields of a project
GET/projects/{project}/custom-fields/{field}custom-fields-readread on projectGet a custom field
POST/projects/{project}/custom-fieldscustom-fields-createadmin on projectCreate a custom field
PUT/projects/{project}/custom-fields/{field}custom-fields-updateadmin on projectUpdate a custom field
DELETE/projects/{project}/custom-fields/{field}custom-fields-deleteadmin on projectDelete a custom field
GET/tasks/{task}/custom-field-valuestask-custom-field-values-listread on taskList the custom field values of a task
PUT/tasks/{task}/custom-field-values/{field}task-custom-field-values-setwrite on taskSet a custom field value on a task
DELETE/tasks/{task}/custom-field-values/{field}task-custom-field-values-clearwrite on taskClear a custom field value on a task

An update of a definition replaces the submitted options: options with an id are updated, options without one are created, and options left out are deleted together with every value that references them. Task list and single task reads accept expand=custom_fields, which embeds custom_fields: [{"custom_field_id", "type", "value"}] (fields without a value are left out; a checkbox set to false counts as a value; the values of a page are loaded in two queries). API tokens need tasks_custom_field_values read_all for the expand.

Filtering and sorting. cf_<id> works in the filter and sort_by parameters wherever the filter syntax does. The comparators by type are listed in API.md. Sorting works for all single-value types, select fields sort by option position, tasks without a value sort last in both directions, and multi_select and user cannot be sorted by (400).

Configuration keys #

The module has no configuration keys of its own. Field values share the file and database settings of the instance.

UI #

  • Definitions: project settings, Custom fields (project.settings.custom-fields), project admins only. Title, type (fixed after creation), required, per-type config and an option list with colours.
  • Task detail: one editor per type under the other task properties. Values save per field.
  • Display: a read-only component renders values in table cells and kanban cards. The Columns menu of a table view lists the custom fields (off by default); a kanban view has a "Card fields" menu. Both choices are stored in the browser (localStorage keys tableViewCustomColumns and kanbanCardFields), not on the server; the view requests expand=custom_fields only while a field is shown.
  • Filter input: shows and accepts field names and option titles (Budget > 100), sends cf_<id> and option ids; saved filters keep the id form, so renaming a field breaks nothing. Names with spaces are double quoted, built-in names win unless quoted, colliding names get the project title appended.

More in DESIGN.md.

Events and interaction with other modules #

  • Events: custom-field.created, custom-field.updated, custom-field.deleted, and task.custom-field-value.updated (task, field, old and new value, doer).
  • Workflows: a transition can list cf_<id> fields as required before it is allowed (workflows).
  • Automation: the task.custom_field_changed trigger listens to task.custom-field-value.updated; conditions can compare cf_<id>; the task.set_custom_field action and vikunja.fields.get / vikunja.fields.set in scripts write values through the same validation. Deleting a field disables rules that reference it with the reason custom_field_deleted (automation).
  • Forms: a form field can target cf_<id>; deleting a used field disables the form (forms).
  • Reports: select, multi select, user, checkbox and rating fields are dimensions; number, currency, rating and progress fields are measurable (dashboards and reports).
  • Approvals: a user field can be an approver source (approvals).

Limits and safety #

  • A definition title is at most 250 characters; option titles 250; precision 0 to 10; max_rating 1 to 10.
  • There is no cap on fields per project or options per field.
  • value_text is a text column (64 KB on MySQL) and text values are not length-checked on write.
  • Date = compares the exact stored instant; use a range for a day.

Known gaps and open decisions #

From the roadmap:

  • Not exposed over MCP.
  • No cap on fields per project or options per field; no length check on text values.
  • vikunja.tasks.find in scripts with cf_ filters was not tested.
  • UI: hover and focus styling and the read-only state for users without write access were not exercised in a browser; long text shows a single clipped line until focused.
  • Which databases the custom field tests have been run on is recorded in the roadmap.

Where the code lives #

WhatWhere
Models, validation, valuespkg/models/custom_fields.go, pkg/models/custom_field_values.go
Permissionspkg/models/custom_fields_permissions.go
Filter and sortpkg/models/custom_field_filter.go
Expandpkg/models/custom_field_expand.go
Eventspkg/models/custom_field_events.go
Errorspkg/models/error_custom_fields.go (20001 to 20005)
Routespkg/routes/api/v2/custom_fields.go
Migrationpkg/migration/20261122120000.go
Testspkg/models/custom_fields_test.go, pkg/models/custom_field_filter_test.go, pkg/models/custom_field_expand_test.go, pkg/webtests/huma_custom_field_test.go, pkg/webtests/huma_custom_field_filter_test.go
Frontendfrontend/src/components/custom-fields/, frontend/src/views/project/settings/ProjectSettingsCustomFields.vue, frontend/src/client/queries/customFields.ts, frontend/src/helpers/customFields.ts, customFieldDisplay.ts, customFieldFilter.ts

Source of this page on GitHub