RecType YAML
Fields, child tables, naming, permissions and submittable RecTypes in rectypes/*.yaml.
Each RecType is one file in rectypes/, named after the RecType in snake case (Book Loan is book_loan.yaml). The compiler refuses an unknown key and names the file and path, such as fields[4].options.
A submittable RecType with a child table
ERP's Cost Center Allocation, shortened:
schema: 1
name: Cost Center Allocation
module: Accounts
autoname: "CC-ALLOC-.#####"
is_submittable: true
sort_field: creation
sort_order: DESC
fields:
- {fieldname: main_cost_center, fieldtype: Link, label: Main Cost Center, options: Cost Center, reqd: true, in_list_view: true,
link_filters: [[company, "=", {expr: doc.company}], [is_group, "=", false]]}
- {fieldname: company, fieldtype: Link, label: Company, options: Company, reqd: true, fetch_from: main_cost_center.company}
- {fieldname: column_break_2, fieldtype: Column Break}
- {fieldname: valid_from, fieldtype: Date, label: Valid From, reqd: true, default: Today, in_list_view: true}
- {fieldname: section_break_5, fieldtype: Section Break}
- {fieldname: allocation_percentages, fieldtype: Table, label: Cost Center Allocation Percentages,
options: Cost Center Allocation Percentage, reqd: true}
permissions:
- {role: Accounts User, rights: [read, write, create, delete, submit, cancel, amend, report, export, share, print, email]}The child RecType sets istable: true. Its rows live under the parent's Table field, and an expression on a row reads the parent as parent.
schema: 1
name: Cost Center Allocation Percentage
module: Accounts
istable: true
fields:
- {fieldname: cost_center, fieldtype: Link, label: Cost Center, options: Cost Center, reqd: true, in_list_view: true,
link_filters: [[company, "=", {expr: parent.company}]]}
- {fieldname: percentage, fieldtype: Percent, label: "Percentage (%)", reqd: true, in_list_view: true}A submittable RecType gets an amended_from column without declaring it. Declare it as a field only to place it on the form.
RecType keys
The common keys. RecType key reference lists all of them, and Form and list options covers buttons, colours and views.
| Key | Meaning |
|---|---|
schema | Always 1 |
name, module | Title Case name, and one of the manifest's modules |
autoname | How records are named. See below |
istable | A child RecType |
issingle | One record, such as a settings page |
is_submittable | Draft, Submitted and Cancelled states (docstatus 0, 1, 2) |
is_tree | Adds a parent Link and is_group |
track_changes | Keeps a Version per save |
allow_rename | Writers may rename or merge records |
title_field, search_fields | What Link searches show |
sort_field, sort_order | The list's default order |
quick_entry, editable_grid | Desk form behaviour |
permissions | Role rules. See Permissions |
row_rules, inherit_permission | Per-record access |
has_web_view, route | Records with a public page |
description | What the records are, also read by the AI catalog |
Naming
autoname | Example name |
|---|---|
"field:title" | The value of title |
"naming_series:" | From the record's naming_series Select, such as SAL-ORD-.YYYY.- |
"CC-ALLOC-.#####" | A fixed series, CC-ALLOC-00001 |
autoincrement | 1, 2, 3 |
hash | A random name |
prompt | The user types it |
UUID | A UUID |
Field keys
| Key | Meaning |
|---|---|
fieldname, fieldtype, label | Required except label |
options | Depends on the type: the target of a Link, the child of a Table, the lines of a Select |
reqd, unique, default | default takes a YAML scalar, or Today, Now, __user |
depends_on, mandatory_depends_on, read_only_depends_on | Expressions over doc |
fetch_from | <link field>.<field>, copied when the Link changes |
link_filters | [field, operator, value] on a Link's target. A value can be {expr: doc.company} |
in_list_view, in_standard_filter, in_global_search | Where the field shows up |
read_only, hidden, allow_on_submit, no_copy, set_only_once | Edit rules |
permlevel | The field's permission level, 0 by default |
precision, length, non_negative | Value limits |
Field types
Data, Small Text, Text, Long Text, Text Editor, Markdown Editor, HTML Editor, Code, JSON, Int, Float, Currency, Percent, Check, Select, Link, Dynamic Link, Table, Table MultiSelect, Date, Datetime, Time, Duration, Attach, Attach Image, Password, Read Only, Color, Rating, Geolocation, Phone, Autocomplete, Signature, Barcode, Icon, Image, Attachment Gallery, Button, HTML, Heading.
Layout types: Section Break, Column Break, Tab Break, Fold.
Currency, Float and Percent store exact decimals. Code reads and writes them as strings, such as "10.5".
Changing a RecType
Edit the YAML and run cardinal migrate -t HOST. The schema sync adds columns and may widen a type to one that holds every old value. It never drops or narrows a column. To rename a field, add the new one and copy values in a patch.