Get Record

Overview

The Get Records interaction lets you fetch data from Salesforce and store it in a variable in your Dynamic Component. This is the primary method for populating your component with data that is not automatically available from the page context.

You can use this interaction to:

  • Retrieve details of a related record (e.g., getting the Parent Account details while on a Contact page).

  • Fetch a specific record based on a user's selection or input.

  • Refresh data after a record is updated to keep the UI up to date.


Configuring the Get Records Interaction

The configuration process involves three main steps: defining where to store the data, building the query, and selecting which fields to retrieve.

1. Define the Output Variable

Before configuring the interaction, you need a "container" to hold the data you retrieve.

  • Open the Variables panel (Database icon).

  • Create a New Variable.

  • Data Type: Select Record (since you are fetching a single record).

  • Object: Select the object you will be querying (e.g., Account).

  • API Name: Give it a clear name (e.g., parentAccountData).

2. Configure the Query

  • Add the interaction (e.g., to an On Load event or a Button On Click).

  • Action Type: Select Get Records.

  • Object: Select the Salesforce Object you want to query.

  • Output Variable: Select the variable you created in Step 1 (e.g., {!parentAccountData}).

3. Set the Filter Criteria

You must tell the system exactly which record to find using a "Where" clause.

  • Field: Select the field on the target object to filter by (e.g., Id).

  • Operator: Select the comparison (e.g., Equals).

  • Value: Select the source value to match.

    • Example: To find the Account associated with the current Case, you would map:

      • Field: Id

      • Value: {!$Component.record.AccountId} (The Account ID from the current page).

4. Select Fields to Retrieve

You must explicitly specify which fields to fetch. If a field is not selected here, it will be empty in your variable, even if the record has data for it.

  • Click Select Fields.

  • Check the boxes for every field you need to display or use (e.g., Name, Industry, Phone).

  • Crucial: Always select the Id field if you plan to use this data for Update or Delete actions later.


Common Use Cases

Goal: Display the "Parent Account's Industry" on a Case record page.

  1. Event: Select the component's On Load interaction.

  2. Action: Get Records.

  3. Filter: Id Equals {!$Component.record.AccountId}.

  4. Fields: Select Industry (and Id).

  5. Output: Store in {!parentAccountVar}.

  6. UI: Bind a Text Block or Input to {!parentAccountVar.Industry}.

Scenario B: Refetching Data After an Update

Goal: Refresh the component immediately after a user saves changes, ensuring they see the latest server-side values.

  1. Event: On the "Save" button, create a chain of actions.

  2. Action 1: Update Record (commits the changes).

  3. Action 2: Get Records.

    • Re-run the exact same query used to load the data initially.

    • Store the result in the same variable.

    • Result: The UI updates instantly because the variable driving it has been refreshed.


Important Considerations

"Get First Record" Behavior: This interaction is designed to fetch a single record. If your filter criteria matches multiple records (e.g., "Industry equals Tech"), the system will return only the first record it finds. Always try to filter by unique identifiers (like IDs) to ensure precision.

Handling Empty Results: If no record matches your criteria, the output variable will remain null. You can handle this gracefully by adding a Condition interaction after the Get Records action:

  • If {!myVariable.Id} is empty: Show a "No record found" message or hide the section.

Field Accessibility: The interaction respects Salesforce security. You can only retrieve fields that the current user has permission to view in Salesforce.

Last updated

Was this helpful?