Query VS Variable

When building your Salesforce flows with Avonni components, selecting the right data source is crucial for performance and flexibility. Avonni offers two main options:

Variable Data Source

How It Works

You use standard Salesforce Flow logic (such as Get Records) to fetch data. The results are stored in a Flow variable, which is then linked to your Avonni component.

Best Used For

  • Simple use cases that involve a single object or simple relationships

  • Reusing existing Flow logic where the data has already been retrieved

  • When you want to transform or manipulate the data (e.g., sort, filter, calculate) in the Flow before displaying it

Limitations

  • Subject to the 50,000 record limit of Flow’s "Get Records" element

  • Not suitable for complex queries involving deep relationships or advanced filtering

  • No built-in real-time filtering based on user interaction


Query Data Source

How It Works

You write a SOQL query directly inside the Avonni component configuration. The component runs the query and loads the data automatically.

Best Used For

  • Complex or large queries involving multiple objects, lookups, or filters

  • Situations where you need to retrieve more than 50,000 records

  • Dynamic, interactive components that respond to user input in real time (e.g., filtering, search)

Considerations

  • Requires a basic understanding of SOQL

  • May be less intuitive for Flow beginners compared to using variables

  • Doesn’t allow for complex post-processing logic within the Flow itself


Key Differences at a Glance

Feature
Variable Data Source
Query Data Source

Data Source

Flow variable (Get Records)

Inline SOQL query

Record Limit

50,000

No hard limit

Query Complexity

Low (1–2 related objects)

High (multi-object, filters, joins)

Real-Time Filtering

❌ No

✅ Yes

Ease of Use

✅ Beginner-friendly

⚠️ Requires SOQL knowledge when used with reactive formulas

Which to Choose?

Use a Variable if:

Use a Query if:

You already have a Get Records step in your Flow

You need to pull data dynamically based on user interaction

You want full Flow control over the data

You need faster or more complex queries

You’re working with small datasets

You're working with large or complex datasets

Example: Displaying Contacts

  • Variable: Use a "Get Records" element to fetch contacts based on certain criteria (e.g., Account Name). Store the results in a variable and connect it to an Avonni List component.

  • Query: Write a SOQL query directly in the Avonni List component: SELECT Id, Name, Email FROM Contact WHERE Account.Name = 'Acme'

Dynamic Query Tutorials

These hands-on tutorials walk you through building interactive, data-driven components using reactive queries in Avonni. Reactive queries enable one component’s data to update automatically in response to user interaction with another, eliminating the need for extra Flow logic or screen refreshes.

For example, when a user selects an Account in one Data Table, a second Data Table can instantly show the related Contacts. These examples show you how to implement that kind of dynamic, real-time behavior using SOQL queries directly in your components.

Last updated

Was this helpful?