Skip to main content

Records

Record blocks query data from your collections using a visual query builder or raw SQL. Use them to fetch additional data needed for your automation logic. Open any automation in Automation from the top navigation and click Add Condition, Record or Action to add a record block.

Retrieve types

TypeDescriptionReturns
Find OneReturns a single matching recordObject or null
Find AllReturns all matching recordsArray of objects

Creating a record block

  1. Click Add Condition, Record or Action below any block.
  2. Select Record.
  3. Set up the query in the right panel.

Configuration

FieldRequiredDescription
Retrieve TypeYesFind One or Find All
CollectionYesWhich collection to query
Collection AliasYesShort name to reference the result (for example, manager, orders)

Query builder

Choose between visual query building or raw SQL input.

Visual query builder

Build queries using a form-based panel with the following sections:

Select fields

Choose which fields to retrieve from the collection:

  • Field Selection: Pick individual fields from the collection
  • Aggregation: Apply functions like COUNT, SUM, AVG, MIN, MAX to numeric fields
  • Aliases: Give aggregated fields custom names (automatically enabled when using aggregation)

Example field configurations:

Basic field selection:

Field: customer_name, Aggregator: NONE (no alias needed)
Field: order_date, Aggregator: NONE (no alias needed)

With aggregation:

Field: order_total, Aggregator: SUM, Alias: total_revenue
Field: order_id, Aggregator: COUNT, Alias: order_count
Field: order_total, Aggregator: AVG, Alias: average_order_value

Real-world use cases:

Sales analytics:

Field: total_amount, Aggregator: SUM, Alias: monthly_revenue
Field: order_id, Aggregator: COUNT, Alias: total_orders
Field: customer_id, Aggregator: COUNT DISTINCT, Alias: unique_customers

Inventory management:

Field: quantity, Aggregator: SUM, Alias: total_stock
Field: product_id, Aggregator: COUNT, Alias: product_varieties
Field: unit_price, Aggregator: AVG, Alias: average_price

User analytics:

Field: user_id, Aggregator: COUNT, Alias: active_users
Field: session_duration, Aggregator: AVG, Alias: avg_session_time
Field: login_count, Aggregator: MAX, Alias: max_logins_per_user

Query conditions

Filter which records to retrieve by adding conditions:

  1. Click + Add Condition in the query section.
  2. Select a Field from the collection.
  3. Choose a Comparison operator.
  4. Enter the Value (can use variables like {{user.managerId}}).

Dynamic values

Reference data from previous blocks in your query conditions. Click the + icon next to the Value input field to select available fields and variables.

Query: Find One from Employees
Condition: id = {{user.managerId}}

This fetches the manager record based on the trigger user's managerId field.

Advanced conditions

Create complex conditions with AND/OR logic:

  • AND groups: All conditions in a group must be true
  • OR groups: At least one condition in a group must be true
  • Nested groups: Combine groups for complex logic

Example complex condition:

(Department = 'Sales' AND Salary > 50000) OR (Department = 'Engineering' AND Experience > 3)

Filters and sorting

Apply advanced filtering and ordering:

  • GROUP BY: Group results by fields (used with aggregations)
  • HAVING: Filter grouped results
  • ORDER BY: Sort results by field and direction
  • LIMIT/OFFSET: Paginate results

Raw SQL query

For advanced users, switch to raw SQL mode:

  • Write custom SQL queries directly
  • Full SQL syntax support with syntax highlighting
  • Auto-completion for table and field names

Example raw query:

SELECT 
COUNT(*) as total_orders,
SUM(total_amount) as revenue,
customer_id
FROM orders
WHERE created_at >= '{{trigger.date}}'
GROUP BY customer_id
HAVING COUNT(*) > 5
ORDER BY revenue DESC
LIMIT 10

Using record data

After a record block, access its data using the alias you defined:

  • Single record: {{manager.name}}, {{manager.email}}
  • Array (Find All): Access individual items in actions that support arrays

Query templates

Use pre-built templates to quickly set up common queries:

  • Select All Fields: Retrieve all fields from the table
  • Count Records: Get total record count
  • Recent Records: Get latest records by date
  • Top Values Analysis: Count and group by field values
  • Numeric Summary: Statistical summary of numeric fields

Query preview

View the generated SQL query before running the automation to ensure accuracy.

Example: Complex analytics query

Trigger: Daily schedule runs
├─ Record: Find All from Orders (alias: orders)
│ Fields: COUNT(*), SUM(total), AVG(total), customer_id
│ Conditions: created_at >= '{{yesterday}}'
│ Group By: customer_id
│ Having: COUNT(*) > 3
│ Order By: SUM(total) DESC
│ Limit: 10
└─ Action: Send Email with top customer analytics

Query scope

Record blocks can reference:

  • Trigger data: {{triggerAlias.field}}
  • Previous record blocks: {{previousRecordAlias.field}}
  • Variables: {{variableName}}

Data flows top-to-bottom — a record block can only use data from blocks above it.

Best practices

  • Use meaningful aliasescustomer is better than record1
  • Query only what you need — Use Find One when you expect one result
  • Leverage aggregation — Use COUNT, SUM, AVG for analytics
  • Test queries — Use query preview to validate SQL before saving
  • Consider performance — Add appropriate LIMITs for large datasets