---
schema_version: "1"
id: 94681d9f6a69c000759de68b38cda3c92aaf68da2e233d355c1547979e2862e0
title: Get Records Element
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/flow_ref_elements_data_get.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_data_get.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 8ca871a9a715fc78982c89875122502d0e7c3514f44684c40fdb33b03adf256f
description: The Get Records element finds all Salesforce or Marketing Object records that meet the filter and sort conditions and stores values from the retrieved records in variables. You can retrieve Salesforce standard and custom object records, or Marketing Object records, by using the Get Records element.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Get Records Element

The Get Records element finds all Salesforce or Marketing Object records that meet the filter and sort conditions and stores values from the retrieved records in variables. You can retrieve Salesforce standard and custom object records, or Marketing Object records, by using the Get Records element.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=platform.flow_ref_supported_editions.htm&amp;release=264.0.0&amp;type=5" title="Learn about the editions and user interfaces that support Flow Builder. Some Flow Builder features integrate with other Salesforce products that require additional licenses.">View supported editions.</a></td></tr></tbody></table>

This video explains what the Get Records element is and why you should use it in a flow.

View this [video](https://play.vidyard.com/3WKdKq49xfPkuZbi3qXUca) in a separate tab.

This transcript provides a text-based version of the video content.

Did you know that Flow is not connected to your data? Flow has no idea what's going on in your Salesforce Org. So how do we get data into a Flow? If only there were a data element to help us get data into Flow? Oh wait, there is. In order to pull information into Flow, we use the Get Records Data Element. Get Records allows you to choose an object to get records from and even set criteria to decide which records to get. You can get one or many records to work with. Within the record, you can either get all the fields or select just the fields you need. Once the records are in the Flow, you can work with the information in several ways. You can inform decisions, update the records that you pulled into the Flow, update other records; all of these decisions, updates, etc., are temporary and exist only in the Flow until the information is sent back to your Salesforce Org. This can be done with the Create, Delete, and Update Records Data Elements. Get Records pulls info into your Flow, and the create, delete, and update records elements push that info back into your Salesforce Org.

## Get Related Records (Beta)

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_note.png)

Note This feature is a pilot or beta service that is subject to the Beta Services Terms at [Agreements - Salesforce.com](https://www.salesforce.com/company/legal/agreements/) or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the [Product Terms Directory](https://ptd.salesforce.com/). Use of this pilot or beta service is at the Customer's sole discretion.

Related records in the Get Records element are available in autolaunched flows. See [Get Related Salesforce Records from a Flow (Beta)](https://help.salesforce.com/s/articleView?id=platform.flow_build_data_get.htm&release=264.0.0&type=5 "Access related records in complex data relationships.. Related records in the Get Records element are available in autolaunched flows.").

## How Many Records to Store

Identify the object with records that you want to find. Narrow the list of returned records by specifying filter conditions and a sort order.

![The Get Records element for the Account object, where All Records up to a specified limit is selected under How Many Records to Store](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_ref_get_records.png)

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d171394e121">Select</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d171394e124">If you want to</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Select" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e121 "><strong class="uicontrol">Only the first record</strong></td>

            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e124 ">
              <p>Store only the first record that meets the specified criteria.</p>
              <p style="margin-bottom:0;">For example,
                use this option to retrieve caller details by finding the first record that
                matches the caller's phone number.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Select" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e121 "><strong class="uicontrol">All records</strong></td>

            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e124 ">
              <p>Store all records that meet the specified criteria. </p>
              <p style="margin-bottom:0;">For example, use this
                option when you want to gather all contacts associated with a specific account for
                a marketing campaign.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Select" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e121 "><strong class="uicontrol">All records, up to a specified limit.</strong></td>

            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e124 ">
              <p>Store all records up to a specified upper limit. </p>
              <p>Specify a number between 2
                and 20,000 as an upper limit. You can use literals, variables, constants, or
                formulas of the number data type in the Maximum Number of Records to Store field.
              </p>
              <p style="margin-bottom:0;">For example, use this option to retrieve the first 50 records so that you
                can analyze a sample from a large dataset. </p>
            </td>

          </tr>
        </tbody>
      </table>

## How to Store Record Data

When you add a Get Records element to a screen flow or an autolaunched flow, Salesforce automatically stores all the record values in a flow variable. When the flow moves to the next element, the values are assigned to the variable.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d171394e193">Select</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d171394e196">If you want to </th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Select" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e193 "><strong class="uicontrol">Automatically store all fields</strong></td>

            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e196 ">
              <p>Automatically store all the fields of the records that meet your specified
                filter conditions. Every field in the retrieved records is stored in a flow
                variable. This option is useful when you must work with multiple fields from the
                records and want to ensure that all data is available without specifying each field
                individually.</p>
              <p style="margin-bottom:0;">For example, use this option to store all opportunity fields when
                you want to analyze every opportunity in your pipeline. You can then use the
                fields for a detailed analysis or use them in subsequent flows.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Select" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e193 "><strong class="uicontrol">Choose fields and let Salesforce do the rest</strong></td>

            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e196 ">
              <p>Manually specify which fields you want to store from the retrieved records.
                With this option, you can be selective about the data that you store, which can be
                more efficient if you only need specific fields.</p>
              <p style="margin-bottom:0;">For example, use this option when
                your customer service rep needs to update only the priority and status of all open
                cases assigned to them. You can reduce complexity and improve performance by
                getting only the needed fields from the records.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Select" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e193 "><strong class="uicontrol">Choose fields and assign variables (advanced)</strong></td>

            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e196 ">
              <p>Store record values manually in a screen flow or autolaunched flow. </p>
              <p style="margin-bottom:0;">For
                example, to calculate the total value of all won opportunities for a specific
                campaign, assign the amount field to a specific variable. Choosing fields and
                assigning variables makes it easy for the flow to add these values and perform
                other calculations based on the total amount. See <a href="https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_data_get.htm&amp;release=264.0.0&amp;type=5">Choose fields and assign variables (advanced)</a></p>
            </td>

          </tr>
        </tbody>
      </table>

## Choose fields and assign variables (advanced)

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d171394e264">If you want to</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d171394e267">Then</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e264 "><strong class="uicontrol">Store field values manually for only the first
                record</strong></td>

            <td data-label="Then" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e267 ">
              <ul>
                <li>Filter by a unique field, such as ID. Otherwise, you can’t guarantee which
                  record’s field values are stored.</li>

                <li>Choose to store field values from the first record together in a record
                  variable or in separate variables.<ul>
                    <li>To store the values together, select the record variable, and then
                      identify the fields whose values that you want to store.</li>

                    <li>To store the values in separate variables, select each field that you want
                      to store, and then select the variable to store each field value in.</li>

                  </ul>
                </li>

              </ul>
            </td>

          </tr>
          <tr class="">
            <td data-label="If you want to" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e264 "><strong class="uicontrol">Store field values manually for more than one
                record</strong></td>

            <td data-label="Then" class="slds-cell-wrap" style="vertical-align:top;" headers="d171394e267 ">
              <p>Store the values in a record collection variable. When you use a record
                collection variable to create, update, or delete multiple records at one time, you
                reduce the number of DML requests in your flow. You’re more likely to stay within
                your org’s limits. See <a href="https://help.salesforce.com/s/articleView?id=platform.flow_concepts_bulkification.htm&amp;type=5&amp;language=en_US" target="_blank">Flow Bulkification in Transactions</a>.</p>
              <p>Here
                are some examples.</p>
              <ul>
                <li>Find the product name or description for a product with a specific bar
                  code.</li>

                <li>Confirm stock availability for a particular item. </li>

                <li>Verify a caller’s identity.</li>

              </ul>
            </td>

          </tr>
        </tbody>
      </table>

## Sort the Retrieved Records

Sort the retrieved records in ascending or descending order based on the selected field. Sort orders are useful when you want to process records in a specific sequence. When you sort records by a date field and select ascending order, the oldest dates show first. If you select descending order, the most recent dates show first. When you sort records by a numerical field and select ascending order, the lowest values show first. If you select descending order, the highest values show first.

When you sort records in ascending order, null values appear at the beginning of the list because null values are considered the smallest possible values. Conversely, when you sort records in descending order, null values appear at the end of the list.

## Find Out How Many Records Were Retrieved

If you want to know the number of records returned by the Get Records element, first create a number variable. Next, assign the number variable the value of the record collection variable from the Get Records element by using the assignment element with the Equals Count operator. When you debug the flow, the value of the number variable tells you how many records were retrieved.

## Error Handling If No Records Are Returned

If your Get Records element is set to "Choose fields and assign variables (advanced)" and no records match the filter conditions, the flow doesn't retrieve any records. The variables you use to store field values are empty or null. This means that any flow logic that depends on these variables needs to handle the case of no data is present. Use decision elements to check whether the variables are empty before proceeding with actions that depend on the retrieved data. If your flow is user-facing, provide feedback to the user indicating that no matching records were found. This feedback can improve the user experience by making it clear why certain actions or data are not available.

## Considerations for Defining Filter Criteria

- When you define multiple filters, the filter logic usually defaults to AND. However, if multiple filters have the same field selected and use the equals operator, the filters are combined with OR.
    
    For example, your filters check whether a case’s Type equals Problem (1), Type equals Feature Request (2), and Escalated equals true (3). At run time, the filters are combined to `(1 OR 2) AND 3`.
- The available filter operators depend on the data type of the selected fields. For details, see [Flow Operators in Data Elements and Record Choice Sets](https://help.salesforce.com/s/articleView?id=platform.flow_ref_operators_filter.htm&release=264.0.0&type=5 "Filter conditions narrow the scope of records that the flow operates on. For example, use filter conditions to update only the contacts that are associated with the Acme Wireless account. When you add an Update Records element, use filter conditions to narrow the scope to just the contacts whose parent account is Acme Wireless. The In and Not In operators are available only in Create Records, Get Records, and Update Records elements.").
- To use a Data Cloud object as the data source, your org must include a data mapping for the object. Data mapping relates Data Lake Object (DLO) fields to Data Model Object (DMO) fields. If your org doesn’t include a mapping, you can’t select a Data Cloud data space or object in the Get Records element.
- Marketing Object records are available with Starter Suite, Marketing Cloud Growth, and Marketing Cloud Advanced editions. To use a Marketing Object as the data source, you need Read, Create, Edit, and Delete permissions on Marketing Objects.

#### See Also

- [Flow Operators in Data Elements and Record Choice Sets](https://help.salesforce.com/s/articleView?id=platform.flow_ref_operators_filter.htm&release=264.0.0&type=5 "Filter conditions narrow the scope of records that the flow operates on. For example, use filter conditions to update only the contacts that are associated with the Acme Wireless account. When you add an Update Records element, use filter conditions to narrow the scope to just the contacts whose parent account is Acme Wireless. The In and Not In operators are available only in Create Records, Get Records, and Update Records elements.")
- [Flow Elements](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements.htm&release=264.0.0&type=5 "An element represents an action that the flow can run. Examples include reading or writing Salesforce data, displaying information and collecting data from flow users, runnning business logic, or manipulating data.")
- [Customize What Happens When a Flow Fails](https://help.salesforce.com/s/articleView?id=platform.flow_build_logic_fault.htm&release=264.0.0&type=5 "Learn how fault paths customize what happens when a flow fails. Choose how to notify admins, guide users, and take a follow-up action.")
- [Move and Connect Elements to Change a Flow Route](https://help.salesforce.com/s/articleView?id=platform.flow_build_logic_route_add.htm&release=264.0.0&type=5 "Identify which elements the flow runs and in what order by connecting the elements on your canvas together. To change the run order, move elements and add or remove connectors.")