Gradient Works Docs
ProductDynamic BooksPricingRequest Demo
  • Welcome
  • ACCOUNT RESEARCH
    • Overview
      • Features
    • Market Map
      • Account Import
        • Salesforce
        • HubSpot
      • Salesforce Integration
        • How to Install Similar Accounts Component
      • CRM Export
        • Salesforce
        • HubSpot
      • FAQs
        • Attributes in Market Map
    • AI Researcher
      • How to create & configure an AI Researcher
      • Writing effective prompts
      • Prompt examples
      • Managed AI Researcher
    • Lookalikes
    • Credits
  • Bookbuilder
    • Overview
    • Enroll Accounts
    • Target Books
      • Target Book Report
      • Edit Reps
    • Account Coverage
      • Market Coverage
      • Rep Coverage
      • Working Activities
    • Transfer Accounts
      • Concepts
      • Account Pool
      • Distributions
      • Retrievals
      • Returns
      • Templates
      • Scheduling
      • Troubleshooting
    • How-to Guides
      • How to Rank Accounts for Distributions and Retrievals
      • How to Use the "Is In" Operator
  • Routing
    • Overview
    • Dashboard
    • Round Robin Queues
      • Create Queues
      • User Availability Status
      • User Working Hours
    • Users
    • Capacity Meters
    • Lead and Account Matching
    • Automation
      • Automation Executions
      • Log Entries
  • Automation Builder Kit (ABK)
    • Getting Started
    • Actions
      • Assignment
        • Directly Assign Items
        • Round Robin Assign Single Item
        • Round Robin Assign Multiple Items
        • Schedule and Assign Single Item
      • Dynamic Books
        • Retrieval
      • Flow Lifecycle
        • Execute Subflow
        • Failed
        • Finish
        • Resume
        • Start
      • Leads
        • Convert Lead
        • Convert Multiple Leads
      • Logs
        • Log Message
      • Matching
        • Match Account to Account
        • Match Lead to Account
        • Match Lead to Contact
        • Match Lead to Lead
      • Next Steps
        • Add Person to Campaign
        • Add Person to Sales Engagement Cadence
        • Check Person Enrollment in Cadence
        • Create Task
        • Send Single Assignment Email
        • Send Slack Message
      • Users
        • Get Used Capacity
        • Update Capacity
        • Update Weight
      • Utils
        • Evaluate Domain against Denylist
      • Advanced
        • Build Record Map from Lookup
        • Build Record Map from Field
        • Build Text Collection from Field
        • Convert ItemAssigned to Assignment
        • Execute SOQL
        • Get Record from Record Map
        • Assign Pending Items for Multiple Queues
        • Assign Pending Items for Single Queue
        • Enqueue Multiple Items
        • Enqueue Single Item
    • Models
      • AccountMatchResult
      • AccountToAccountMatch
      • Assignment
      • ConvertLeadRequest
      • ConvertLeadResult
      • DomainEvaluationResult
      • GenericSObject
      • LeadToAccountMatch
      • LeadToContactMatch
      • LeadToLeadMatch
      • QueueUserWeight
      • RecordMap
  • Integrations
    • Getting Started
    • Slack
    • Google Workspace
    • Microsoft 365
    • Salesloft
    • Outreach
  • Advanced
    • Salesforce Permissions
  • Miscellaneous
    • Changelog
Powered by GitBook
On this page
  • Inputs
  • Outputs
  1. Automation Builder Kit (ABK)
  2. Actions
  3. Advanced

Build Record Map from Lookup

PreviousAdvancedNextBuild Record Map from Field

Last updated 2 years ago

Takes a collection of records as input and the name of a lookup field specified as lookupField. This will then query for all the related records of the object specified by the lookupField. The fields loaded for the related records are defined by selectFields. This provides an efficient way to query for a large number of related records at once.

To use the later in your Flow, make sure to select Store Output Variables and assign it to a variable resource with a data type of Apex-Defined and an apex class of GradientWorks__RecordMap. When creating the resource, do not check "Allow multiple values (collection)".

For example, consider the following Flow structure:

  1. Use Get Records to retrieve a collection of Contacts

  2. Use a Loop over the collection of Contacts

  3. Use Get Records inside the loop to retrieve the Account related to each Contact using Contact.AccountId

This works, but performs an additional SOQL query for each Contact. If you have 50 Contacts, your Flow will perform 51 queries. One to get the original Contact list and then one per Contact. You will rapidly hit Salesforce governor limits and your Flow may run slowly.

This action allows for a pattern like so:

  1. Use Get Records to retrieve a collection of Contacts

  2. Use with the Contacts as input to get a of related Accounts using AccountId as the lookupField and store the to an output variable.

  3. Use a Loop over the collection of Contacts

  4. Use inside the loop with Contact.AccountId as the key to get the related Account

While this requires an extra step, it only uses 2 SOQL queries: one to get the list of contacts and one to retrieve all the related accounts. Your flow will be much less likely to hit governor limits and will run more quickly.

Inputs

Name
Required
Type
Description

input

Yes

List<SObject>

A collection of input records with lookup fields

lookupField

Yes

String

selectFields

Yes

String

A comma-delimited list of fields on the related object you want to include. e.g. Id, Name, CustomField__c. You must specify at least one field.

Outputs

Name
Type
Description

recordMap

The lookup field on each input record containing the reference to the record you want to put in the . e.g. AccountId or OwnerId.

Contains records of the type referenced by the lookup field. The keys are the Ids of the related records. e.g. If your lookupField is a lookup for Account, the records in the will be Account records and the key will be the Id of each Account.

RecordMap
Build Record Map from Lookup
RecordMap
RecordMap
Get Record from Record Map
RecordMap
RecordMap
RecordMap