cardinal

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:

erp/rectypes/cost_center_allocation.yaml
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.

erp/rectypes/cost_center_allocation_percentage.yaml
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.

KeyMeaning
schemaAlways 1
name, moduleTitle Case name, and one of the manifest's modules
autonameHow records are named. See below
istableA child RecType
issingleOne record, such as a settings page
is_submittableDraft, Submitted and Cancelled states (docstatus 0, 1, 2)
is_treeAdds a parent Link and is_group
track_changesKeeps a Version per save
allow_renameWriters may rename or merge records
title_field, search_fieldsWhat Link searches show
sort_field, sort_orderThe list's default order
quick_entry, editable_gridDesk form behaviour
permissionsRole rules. See Permissions
row_rules, inherit_permissionPer-record access
has_web_view, routeRecords with a public page
descriptionWhat the records are, also read by the AI catalog

Naming

autonameExample 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
autoincrement1, 2, 3
hashA random name
promptThe user types it
UUIDA UUID

Field keys

KeyMeaning
fieldname, fieldtype, labelRequired except label
optionsDepends on the type: the target of a Link, the child of a Table, the lines of a Select
reqd, unique, defaultdefault takes a YAML scalar, or Today, Now, __user
depends_on, mandatory_depends_on, read_only_depends_onExpressions 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_searchWhere the field shows up
read_only, hidden, allow_on_submit, no_copy, set_only_onceEdit rules
permlevelThe field's permission level, 0 by default
precision, length, non_negativeValue 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.

On this page