Skip to main content

Overview

Record automations allow you to automatically execute actions when changes happen to your table data. Build powerful workflows that validate data, call external APIs, send notifications, and more.

Event-Driven

Trigger automations on create, update, or delete

Validation

Validate data before changes are committed

Conditional Logic

Execute actions based on custom conditions

Multiple Actions

Chain multiple actions in a single automation

Automation Structure

Every automation consists of four parts, executed in order:
┌─────────────┐     ┌──────────────┐     ┌─────────────────────────────┐
│   TRIGGER   │ --> │  VALIDATION  │ --> │       ACTION BLOCKS         │
│             │     │  (Optional)  │     │  ┌─────────┐  ┌─────────┐  │
│ • Created   │     │              │     │  │Condition│->│ Actions │  │
│ • Updated   │     │ • Script     │     │  └─────────┘  └─────────┘  │
│ • Deleted   │     │ • REST API   │     │  (Repeatable)              │
└─────────────┘     └──────────────┘     └─────────────────────────────┘
  1. Trigger: What event starts the automation
  2. Validation: Checks that must pass before the event is committed
  3. Action Blocks: Conditions and actions to execute (can repeat multiple blocks)

Triggers

Triggers define when an automation runs. You can set up automations for three types of record events.

Trigger Types

TriggerFires WhenUse Cases
Record CreatedA new record is added to the tableWelcome emails, initial status setup, create related records
Record UpdatedAn existing record is modifiedStatus change notifications, sync to external systems
Record DeletedA record is removed from the tableCleanup related data, archive notifications

Combining Triggers

You can combine multiple triggers in a single automation when the validation and actions are the same:
1

Create Automation

Open the automation builder for your table
2

Select Multiple Triggers

Check multiple trigger types (e.g., both “Created” and “Updated”)
3

Configure Once

The validation and actions apply to all selected triggers
Combining triggers is useful when you want the same behavior regardless of whether a record is new or modified (e.g., always validate email format).

Validation

Validations run before the trigger event is committed. If validation fails, the entire operation is rolled back.

How Validation Works

User Action (Create/Update/Delete)

   Validation Runs

   ┌─────────────┐
   │ Passes?     │
   └─────────────┘
     │         │
    Yes        No
     ↓          ↓
  Commit     Rollback
  Changes    + Error

Validation Types

1. Script Validation

Use JavaScript to validate data programmatically. Best for:
  • Checking static conditions
  • Validating data within ERPLite
  • Complex business rules
Example: Validate email format
// Access record data via 'data' object
const email = data.email;
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

if (!emailRegex.test(email)) {
  return {
    valid: false,
    message: "Please enter a valid email address"
  };
}

return { valid: true };
Example: Validate date range
const startDate = new Date(data.start_date);
const endDate = new Date(data.end_date);

if (endDate <= startDate) {
  return {
    valid: false,
    message: "End date must be after start date"
  };
}

return { valid: true };
Example: Validate based on other fields
// If status is "Approved", require approver field
if (data.status === "Approved" && !data.approver) {
  return {
    valid: false,
    message: "Approver is required when status is Approved"
  };
}

return { valid: true };

2. REST API Validation

Call an external API to validate data. Best for:
  • Information not available in ERPLite
  • External system verification
  • Third-party validation services
Configuration:
FieldDescription
URLThe API endpoint to call
MethodHTTP method (GET, POST, etc.)
HeadersRequest headers (auth tokens, content-type)
BodyRequest payload (can include record data)
Success ConditionJavaScript expression to evaluate response
Example: Validate address with external service
// API Configuration
{
  "url": "https://api.addressvalidator.com/validate",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer {{secrets.ADDRESS_API_KEY}}",
    "Content-Type": "application/json"
  },
  "body": {
    "address": "{{data.address}}",
    "city": "{{data.city}}",
    "country": "{{data.country}}"
  }
}

// Success Condition
response.data.isValid === true
Example: Check inventory availability
// API Configuration
{
  "url": "https://inventory.company.com/api/check",
  "method": "POST",
  "body": {
    "sku": "{{data.product_sku}}",
    "quantity": "{{data.quantity}}"
  }
}

// Success Condition
response.data.available >= data.quantity

Validation Conditions

You can add conditions to determine whether a validation should run:
// Only validate if status changed to "Approved"
if (trigger === 'update' && data.status === 'Approved' && oldData.status !== 'Approved') {
  // Run validation
}
This allows you to:
  • Skip validation for certain scenarios
  • Apply different validations based on data
  • Optimize performance by avoiding unnecessary checks

Action Blocks

Action blocks contain conditions and actions. You can have multiple action blocks in a single automation, each with its own condition.

Structure

Action Block 1:
├── Condition: [JavaScript expression]
└── Actions:
    ├── Action 1
    ├── Action 2
    └── Action 3

Action Block 2:
├── Condition: [JavaScript expression]
└── Actions:
    ├── Action 1
    └── Action 2

Conditions

Conditions determine whether an action block executes. Write JavaScript expressions that return true or false. Example conditions:
// Execute only when status is "Approved"
data.status === "Approved"

// Execute only for high-value orders
data.total_amount > 10000

// Execute when priority changed to "Urgent"
data.priority === "Urgent" && oldData.priority !== "Urgent"

// Execute based on user role
user.role === "Manager"

// Combine conditions
data.status === "Completed" && data.requires_notification === true

Action Types

1. Create Record

Create a new record in any table.
ConfigurationDescription
TableTarget table to create record in
Field MappingMap values to the new record’s fields
Example: Create audit log entry
{
  "tableType": "audit_logs",
  "data": {
    "action": "Record Updated",
    "table": "{{tableType}}",
    "record_id": "{{recordId}}",
    "user": "{{user.name}}",
    "timestamp": "{{now}}"
  }
}

2. Update Record

Update an existing record in any table.
ConfigurationDescription
TableTarget table
Record IDID of record to update (can be dynamic)
Field UpdatesFields and values to update
Example: Update parent record status
{
  "tableType": "orders",
  "recordId": "{{data.order_id}}",
  "data": {
    "status": "Has Items",
    "last_updated": "{{now}}"
  }
}

3. Delete Record

Remove a record from a table.
ConfigurationDescription
TableTarget table
Record IDID of record to delete

4. Create Task

Create a new task in a workflow.
ConfigurationDescription
WorkflowTarget workflow
Initial DataData fields for the task
AssignmentUser or team to assign

5. Update Task

Modify an existing workflow task.
ConfigurationDescription
Task IDID of task to update
Field UpdatesFields and values to update

6. Delete Task

Remove a workflow task.

7. Task Status Change

Transition a task to a different state.
ConfigurationDescription
Task IDID of task
TransitionTarget state/transition to execute

8. Execute Script

Run custom JavaScript code. Example: Complex calculations
// Calculate discount based on quantity
const quantity = data.quantity;
let discount = 0;

if (quantity >= 100) discount = 0.2;
else if (quantity >= 50) discount = 0.1;
else if (quantity >= 20) discount = 0.05;

// Return values to use in subsequent actions
return {
  discount_rate: discount,
  final_price: data.unit_price * quantity * (1 - discount)
};

9. Call External API

Make HTTP requests to external services.
ConfigurationDescription
URLAPI endpoint
MethodGET, POST, PUT, PATCH, DELETE
HeadersRequest headers
BodyRequest payload
Response HandlingHow to process the response
Example: Sync to external CRM
{
  "url": "https://api.crm.com/contacts",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer {{secrets.CRM_API_KEY}}",
    "Content-Type": "application/json"
  },
  "body": {
    "name": "{{data.customer_name}}",
    "email": "{{data.email}}",
    "phone": "{{data.phone}}",
    "source": "ERPLite"
  }
}

10. Send Email

Send email notifications.
ConfigurationDescription
ToRecipient email(s)
SubjectEmail subject line
BodyEmail content (supports templates)
CC/BCCAdditional recipients
Example: Send notification email
{
  "to": "{{data.assigned_user.email}}",
  "subject": "New Task Assigned: {{data.title}}",
  "body": `
    Hello {{data.assigned_user.name}},

    A new task has been assigned to you:

    Title: {{data.title}}
    Priority: {{data.priority}}
    Due Date: {{data.due_date}}

    Please log in to ERPLite to view details.
  `
}

Creating an Automation

1

Open Automation Builder

Go to your table settings and click Automations or Configure Automations
2

Create New Automation

Click + Add Automation
3

Name Your Automation

Give it a descriptive name (e.g., “Send welcome email on customer creation”)
4

Select Trigger(s)

Choose one or more trigger events
5

Add Validation (Optional)

Configure script or API validation if needed
6

Add Action Blocks

Create action blocks with conditions and actions
7

Test

Test the automation with sample data
8

Save & Activate

Save and enable the automation

Common Automation Patterns

Trigger: Record Created or Updated Actions: Call External API to sync dataUse case: Keep CRM, ERP, or other systems in sync
Trigger: Record Updated Condition: data.status !== oldData.status Actions: Send Email to stakeholdersUse case: Notify team when order status changes
Trigger: Record Updated Condition: data.parent_status === "Closed" Actions: Update related child recordsUse case: Close all sub-tasks when parent is closed
Trigger: Record Created Validation: REST API to verify customer credit Actions: Create record if valid, reject if notUse case: Verify credit limit before creating order
Trigger: Record Created, Updated, Deleted Actions: Create Record in audit_logs tableUse case: Maintain compliance audit trail
Trigger: Record Created Condition: !data.assigned_to Actions: Execute Script to determine assignee, Update RecordUse case: Auto-assign based on region or workload

For AI Agents

Automation Configuration Structure

interface TableAutomation {
  id: string;
  name: string;
  description?: string;
  isActive: boolean;
  triggers: ('created' | 'updated' | 'deleted')[];
  validation?: {
    type: 'script' | 'rest_api';
    condition?: string;  // When to apply validation
    config: ScriptValidation | RestApiValidation;
  };
  actionBlocks: ActionBlock[];
}

interface ScriptValidation {
  script: string;  // JavaScript code
  errorMessage?: string;
}

interface RestApiValidation {
  url: string;
  method: 'GET' | 'POST' | 'PUT' | 'PATCH';
  headers?: Record<string, string>;
  body?: any;
  successCondition: string;  // JavaScript expression
  errorMessage?: string;
}

interface ActionBlock {
  id: string;
  condition: string;  // JavaScript expression
  actions: Action[];
}

interface Action {
  type: 'create_record' | 'update_record' | 'delete_record' |
        'create_task' | 'update_task' | 'delete_task' | 'task_status_change' |
        'execute_script' | 'call_api' | 'send_email';
  config: any;  // Type-specific configuration
}

API: Get Table Automations

GET /zorp-tables-service/table/:tableType/metadata
Authorization: Bearer {secretKey}
Response includes automations array in metadata.

API: Create/Update Automation

POST /zorp-tables-service/table/automation
Authorization: Bearer {secretKey}
Content-Type: application/json

{
  "tableType": "my_table",
  "automation": {
    "name": "Notify on status change",
    "triggers": ["updated"],
    "validation": null,
    "actionBlocks": [
      {
        "condition": "data.status !== oldData.status",
        "actions": [
          {
            "type": "send_email",
            "config": {
              "to": "{{data.owner.email}}",
              "subject": "Status Changed",
              "body": "Record {{recordId}} status changed to {{data.status}}"
            }
          }
        ]
      }
    ]
  }
}

Available Variables in Automations

VariableDescription
dataCurrent record data
oldDataPrevious record data (for updates)
recordIdCurrent record ID
tableTypeCurrent table type
triggerTrigger type (‘created’, ‘updated’, ‘deleted’)
userCurrent user object
nowCurrent timestamp
secretsAccess to stored secrets

UI Components

ComponentLocationPurpose
AutomationBuilder/src/views/automationBuilder/Main automation editor
TriggerBlocksAutomation builderConfigure triggers
ActionBlocksAutomation builderConfigure action blocks
ExpressionEditorLow-code scriptingJavaScript editor

Event Tracking

// Automation events
TableRSEvents.TABLE_AUTOMATION_CREATED
TableRSEvents.TABLE_AUTOMATION_UPDATED
TableRSEvents.TABLE_AUTOMATION_DELETED
TableRSEvents.TABLE_AUTOMATION_EXECUTED
TableRSEvents.TABLE_AUTOMATION_FAILED