Search FlexiRule docs

Recent
Pinned

Press Esc to close. Use arrow keys and Enter inside results. Searches are remembered locally.

FlexiRule Docs

Query Records

Read records or query results for use in a visual rule.

Improve this page

Query Records#

Query Records is a data-reading action with several distinct modes. Choose a mode based on the result your next step needs, configure the fields and filters exposed by that mode, and store the result for downstream actions.

A query does not itself update the matched records. Use Assignment for supported assignments in the current context or Document Action for supported operations on a target document.

Important: Query modes have different backend implementations and result shapes. Do not assume that a configuration or output from one mode is interchangeable with another.

Choose the right mode#

ModeUse it when you need…Result shape / notes
Fetch RecordsA configurable collection query with fields, filters, sorting, limit, offset, and related options exposed by the UIList of records; uses Frappe Query Builder compatibility path
Query ListAn existing list-oriented queryPreserve legacy configuration and verify the selected fields/output
Query DocA single target document or recordSingle-record or full-document output, depending on configuration
Exist RecordTo check whether a matching record existsYes/no result
Query ReportA supported existing reportReport output; requires a Report target
Count / Sum / Average / Min / MaxA supported aggregate resultNumeric/value result; aggregate modes have their own configuration requirements
Group ByA grouped result supported by the selected configurationGrouped rows; do not assume arbitrary aggregation expressions are supported

See Which Query Mode Should I Use? for a decision table.

Typical configuration path#

  1. Add Query Records to the canvas.
  2. Choose a Query Mode.
  3. Select the required target DocType or report, depending on the mode.
  4. Configure the fields, filters, sorting, limits, or other options actually shown for that mode.
  5. Set Result Handling to store or update a context variable as appropriate.
  6. Debug the rule and inspect the returned value before referencing it downstream.

The backend publishes mode-level contracts that determine operation options, required fields, result types, and which controls are shown. Use the selected mode’s controls as the authority; not every setting applies to every mode.

Results, variables, and execution#

Query Records resolves configured input mappings and supported dynamic values before dispatching to the selected mode handler. The returned result then follows the action’s configured next step. How the result is represented depends on the selected mode; list rows, a single document, a boolean, aggregate values, and report output are not interchangeable.

Use the result-handling controls to save the result in context, then choose it in later actions using the shared value controls. Always test both matching and empty-result cases.

Permissions#

Query Records exposes a Skip Permissions setting with a conditional audit-reason field. The backend checks permission-bypass eligibility before executing the selected query. Bypassing read permissions can reveal records the current user would not otherwise access, so leave it disabled unless the bypass is explicitly approved. Exact behavior depends on the selected mode and its implementation.

Compatibility and limitations#

Fetch Records is a newer mode backed by frappe.qb.get_query; it is not a rename or automatic replacement for Query List. Existing legacy configurations should be preserved unless the application explicitly implements a migration. Query Builder’s supported filter syntax and behavior depend on the installed Frappe version.

Which Query Mode Should I Use? Choose the Query Records mode that matches the required result and implementation. Query Doc Find one specific item and retrieve its details. Fetch Records Configure the newer Query Records mode backed by Frappe's Query Builder API. Query List Retrieve a list-oriented result for use in later rule steps. Exist Record Check if a record exists without retrieving data. Query Report Retrieve data using an existing system report. Count Determine the total number of records matching your criteria. Sum Calculate the total of a numeric field across multiple records. Average Calculate the mean value of a numeric field. Min / Max Retrieve the smallest or largest value from a group of records. Group By Summarize and categorize data into grouped results.