Conventions
These conventions are optional, and the platform does not enforce them. Where it does refuse something, the item says so and gives the error code. The conventions keep a catalog consistent, so that whoever knows one module can read the next, and an agent can tell from a name what a table or field holds without reading its records. An agent with the use-semantius skill follows them when it builds a module, and checks a module against them when you ask for a review.
Steps that only some users may take, approvals, and what each role can see are covered in the guide Workflow States, Gates and Access. On this page, <slug> stands for the module’s slug.
Modules
| Column | Convention |
|---|---|
module_name | The name on the module’s tile and in its section of the app. Keep acronyms as acronyms: CRM, ITSM. |
module_slug | Set it yourself, short and lowercase, with words joined by -, such as ben-admin for Benefits Administration. Left empty, it is made from the full name. It appears in the module’s URLs and starts the name of each of its permissions. |
description | A tagline of at most 60 characters. For an acronym, what it stands for: Customer Relationship Management. |
view_permission | <slug>:read. A new module is visible to everyone until it has a view permission of its own; see Creating a module for the order of the three requests. |
manage_permission, admin_permission | <slug>:manage and <slug>:admin. |
default_viewer_role_id, default_manager_role_id, default_admin_role_id | The module’s viewer, manager and admin roles. |
access_scope | The structure of its permissions; see Access scope. |
Entities
table_nameis plural snake_case and names the thing in full:sales_opportunities,order_lines, neveroppsororderLine. It has at most 41 bytes (90273). No two modules can have an entity of the same name, so the name has to make sense on its own.- One real-world thing is one entity. Before adding an entity, look for one that already holds the same thing, in any module, and relate to it instead. People who sign in are always the built-in
users: never create ausersoruserentity of your own. - Always set
singular_labelandplural_label, as the plain noun:ProductandProducts, neverProduct Name. Left empty,singular_labelis made from the table name (vendor_contractsbecomesVendor Contract), andplural_labelis not made at all. descriptionsays what one record is. It becomes the table’s comment, which the API shows.- Keep the default key,
auto_increment, a number the database counts up. Usetypeidfor the root of anis_aorhas_afamily, or when ids are shown outside Semantius, in URLs, emails or another system. A TypeID such asvendor_contract_01h455vb4pex5vsknk084sn02qcannot be guessed and is unique across entities. Itsid_prefixis the entity’s singular. See Keys.
Labels
The label is the field that names a record. Lists and forms show it, and every field that points at the record shows it too, in its <field>_label column. The entity’s label_column names the field; set it when you create the entity. Choose it in this order:
- A name, title or number the record already has, one people use outside Semantius: a product’s name, a contract’s title, a supplier’s invoice number. Set
label_columnto that field, such asproduct_name. - Otherwise, a name made from the records it relates. Set
label_columnto<singular>_nameand let a computed field fill it. An enrollment, for example, is named after its student and its course. When the same student can enroll in the same course twice, include a field that tells the two apart in the name, such as the start date.
Never build the label from the record’s id, such as a computed Request 1042: a list whose names are only numbers tells nobody which record is which. The key itself cannot be the label (90270).
Set label_parent when a record’s name repeats across parents. A section titled “Introduction” exists in many documents, so its label should start with the document’s. Leave it out when the label is already made from the parent, as in case 2.
A junction’s full label is made from its parents’ labels, and it cannot have a label_parent; its records still need a label of their own. See Many to many.
Entity types
entity_type describes who writes an entity’s records. The platform acts only on junction. For the other types the value is a description, and the convention ties each type to the edit_permission the entity gets. Choose the first type that fits:
entity_type | Who writes the records | edit_permission |
|---|---|---|
junction | The people who relate the records it joins. Its only fields, besides key, label and timestamps, are a parent field to each entity it relates. | <slug>:manage, or <slug>:admin when every entity it relates is a catalog. |
computed | Nobody: every field is derived. | Left at its default, admin. |
catalog | Only the module’s admins (holders of <slug>:admin): setup data and reference values that other records point at. | <slug>:admin |
operational_workflow | The people who do the module’s daily work, and some step is restricted to a role, such as an approval. See Gates. | <slug>:manage |
operational_record | The people who do the module’s daily work, with no restricted step. | <slug>:manage |
view_permission is <slug>:read for every type. unclassified, the default, means nobody chose a type: give every entity one. The records a module exists to manage are never a catalog, however few there are.
Fields
- Names are snake_case, descriptive, and include the noun they describe, with no abbreviations:
customer_email_address,total_amount, notcust_emailortotal. An acronym the domain uses as a word, such as PO inpo_number, is fine. A name that starts with_is refused (90224). - A relationship field is named
<target singular>_id, or after the record’s part in the relationship, ending in_id:account_id,assigned_user_id,parent_case_id. - A field that refers to another record is a relationship field, never a copy of the other record’s name, such as a
vendor_nametext field on purchase orders when avendorsentity exists. An identifier from another system, such as a Salesforce account id, stays a text field. - Money is
number, withprecision2, or 4 to 6 for tax and exchange rates.floatanddoubleare for values that are imprecise by nature, such as measurements. - Formats for text:
multilinefor prose,textfor one line. Useratingonly for star ratings and five-point scores. - Leave
field_orderout when creating fields: they are placed in the order they are sent. - Never end a name in
_id_label. Every relationship field gets a read-only column named after it:customer_idgetscustomer_id_label, which holds the customer’s label. A field of your own namedcustomer_id_labelwould hide that column.
Some fields have fixed names, so that rules, gates and other modules can rely on them:
| Field | Name |
|---|---|
| The state of a record that moves through steps | workflow_state: one required enum, its values in the order records move through them, its default the first one. Never status, state or stage, and never a second state field. Its title is the word the domain uses, such as Stage or Status. |
| Who created a record | <verb>_by_user_id, a reference to users with the default $user_id, so that it starts as the user who creates the record: requested_by_user_id, reported_by_user_id. One per entity. When a rule relies on it, such as the requester check of an approval, fill it with a computed field instead, so that no client can change it; see Approval controls. |
| Who took a step, and when | <step>_by_user_id and <step>_at: approved_by_user_id and approved_at. |
| A person with a part in the record | <part>_user_id, named after what the person does: approver_user_id, assigned_user_id, hiring_manager_user_id. |
A field that applies only in some states, such as a rejection reason, gets an input_type_rule, and also a validation rule when it is required in those states; see Fields needed in some states.
Enums
- Every entry is an object with a
valueand alabel. The value is snake_case and is what records store; the label is what people read, in sentence case:{"value": "on_hold", "label": "On hold"}. For a code, the label is the full term:ndais “Non-disclosure agreement”. - Every entry has a
color, in lowercase#rrggbb, and anicon(a Lucide name) where one fits. No two entries of an enum share a color, and red, amber and green go only to entries that mean failure, waiting and success. - Add a
descriptiononly when the label does not explain itself, such as an internal code, or two choices a user could confuse. - For values a record moves through, list them in that order, and give a required enum a
default_value.
Relationships
- Use
parentonly when all three hold: the child is never saved without its parent, not even as a draft or in an import; it is created as part of the work on its parent; and people only ever reach it through its parent, so it has no number of its own that people quote and no list of its own. Otherwise usereference. An order line is aparentof its order and areferenceto its product. - A chain of
parentrelationships holds at most three entities: a parent, its child and that child’s child. - Choose the delete mode by what should happen to the children when their parent is deleted.
cascadedeletes them too: use it only on aparentwhose children mean nothing without the parent, and only when everyone who may delete the parent may also delete the children.restrictrefuses to delete the parent while it has children: use it on every otherparent, on every requiredreference, and wherever records are kept for audit or by law, which are closed or voided instead of deleted.clearempties the field: use it only on an optionalreference. The platform refusesclearon a requiredreference(90257) and on aparent(90282). relationship_labelis a verb from the domain. It reads as a sentence from the record the field points at to the record that holds the field: Account owns Opportunity, Order contains Order Line. Neverhas,references,belongs toorrelates to. The default,has, says nothing, so always set it. Two fields that point at the same entity get different verbs: a task’s creatorcreatedit, its assigneeworks onit.- Label a junction’s
parentfields after the entity at the other end. Onproduct_tags, the fieldproduct_idgets therelationship_labelis tagged with, andsingular_label_parentandplural_label_parentset toTagandTags, so a product’s page lists Tags, not Product Tags.
Permissions and roles
| Item | Convention |
|---|---|
| Permission | <slug>:<action>: crm:read, crm:manage, crm:admin. Each part between colons is made of a-z, 0-9, - and _ and starts with a letter or digit; another name is refused (23514). The platform does not derive the names from the slug. |
| Levels | <slug>:read reads the module, <slug>:manage does its daily work, <slug>:admin maintains its setup data and may take every restricted step. Add hierarchy entries so that each level includes the one below, and <slug>:admin includes every restricted step. |
| Restricted step | <slug>:<verb>_<noun>, such as spend:approve_purchase_request. See Gates. |
| Bundle | <slug>:<role>, such as spend:approver: the one permission held by a role beyond the three levels. It includes what the role may do: <slug>:manage and the restricted steps it takes, or, for a role that does only part of the work, <slug>:read and the entity write permissions below. See Roles. |
| Entity write permission | <slug>:write_<table_name>, such as spend:write_purchase_requests: an entity’s edit_permission when a role does only part of the module’s work. <slug>:manage includes it. |
| Roles | Give every module a viewer, a manager and an admin role, holding the three levels, and one role for each group of people who take a restricted step or do only part of the work, holding its bundle. The name is the module name and the role’s title, such as CRM Manager or Spend Approver. The slug is the module slug and the title in lowercase, joined by _, with any - turned into _: crm_manager, ben_admin_manager. A role slug with - is refused (23514). |
Rules
code: class 99, such as99001. Another code is refused (90905). Number a module’s rules one after another, so that no two share a code.name: snake_case and unique within the entity, such asapprove_purchase_request. The platform keeps it with the rule; it tells people which rule is which.message: what was refused and who may do it, such as “Only a Buyer can order a purchase request.”- To limit a rule to inserts, updates or deletes, test
$mode. Testing$olddoes not work: it is empty on an insert, but set on both an update and a delete. - Name only permissions that exist. The platform saves a rule that names a permission that does not exist, and the check is then false for everyone, administrators included.