Appearance
Configuration
This guide walks you through the steps to create, configure, and attach a Record Behavior script to a table using the admin settings.
How to Configure a Record Behavior
Record Behaviors are managed within the Settings area of your application. Each behavior is a record that links a script to a specific table.
Step 1: Navigate to Record Behaviors
From the main navigation, go to System > Settings > Record Behaviors. This will take you to the table where all behavior scripts are stored.
Step 2: Create a New Record Behavior
Click the New button to open the form for creating a new Record Behavior.
Step 3: Link the Behavior to a Table
In the form, you will see a Table reference field. Select the table you want this behavior to apply to. For example, you would select the Tasks table if you were adding logic to tasks.
Important
A Record Behavior is always linked to a single table. You cannot share the same behavior record across multiple tables.
Step 4: Write the Script
In the Script field, you will write your JavaScript code. The field is a multi-line text editor designed for code.
Your script must be an export default async function that accepts the $form, $db, and $user arguments.
Here is a simple boilerplate you can use to get started:
javascript
export default async ($form, $db, $user) => {
// Your logic will go here.
// Use console.log() for debugging; output appears in the browser's developer console.
console.log(`Executing behavior for event: ${$form.event}`)
}Step 5: Activate the Behavior
Ensure the Is Active checkbox is checked.
Only One Active Behavior Per Table
You can have multiple Record Behavior entries for a single table (e.g., for versioning or drafts), but only one can be active at a time. The system will only execute the single active script for a given table.
Step 6: Save the Record
Click Create to save your new Record Behavior. The logic will be applied immediately to all forms and backend processes for the linked table.
Managing Existing Behaviors
- Editing a Behavior: To change your logic, simply navigate to the
Record Behaviorrecord and edit theScriptfield. The changes will take effect as soon as you save the record. - Deactivating a Behavior: To temporarily disable a behavior without deleting it, uncheck the
Is Activebox and save. - Versioning: You can keep old versions of a script by creating new
Record Behaviorrecords for the same table. Just make sure only the version you want to use is marked asIs Active.
Next Steps
Now that you know how to set up a Record Behavior, it's time to write the logic.
- Scripting Guide: Understand the execution lifecycle.
- API Reference: See the detailed documentation for the
$form,$db, and$userAPIs. - Examples & Best Practices: Explore complete scripts for common use cases.