Sub topic 7
Finding and reading records
This chapter assumes you know the Salesforce data model (objects, fields, records), can navigate Setup, and have a topic with instructions in Agentforce Builder. It covers the three standard actions that locate and read data: Identify Record by Name, Query Records, and Get Record Details.
The three lookup actions
Most conversations start with a record, such as an account, a case, or a contact. The agent must find it before it can summarize or change it. Each lookup action fits a different situation.
| Action | Use it when | Returns |
|---|---|---|
| Identify Record by Name | The user gives a name and you need one record's ID | A record ID and matching record |
| Query Records | The user wants a list or a filtered set of records | Zero or more records with chosen fields |
| Get Record Details | You already have a record ID and need its field values | Field values for that one record |
Identify Record by Name
This action takes a name from the conversation and an object type, then searches for a match. Its main job is to turn "Acme" into a record ID. Later actions, such as a summary or an update, use that ID as input.
The action can return no match or several matches. Your topic instructions should say what to do in both cases. If you leave this out, the agent may pick one match and continue.
Query Records
Query Records answers questions like "Which open cases does Acme have?" The agent builds a query from the user's request. It uses the object, the filter conditions, and the fields to return.
Use it for lists and filters. Don't use it to find one named record. Identify Record by Name is simpler and more predictable for that.
Get Record Details
Get Record Details reads fields from a record whose ID is already known. The ID usually comes from an earlier Identify Record by Name or Query Records step. This is the action to use for "What is the phone number on that account?"
Writing instructions for lookups
Instructions tell the agent the order of steps and what to do when a lookup is ambiguous. This example follows the pattern from the Account Support topic.
1. When the user names an account, first find the account record, then use the result for any later step.
2. If you cannot find exactly one matching record, ask the user to clarify instead of guessing.
3. Use the record ID from the first lookup for every later action in this conversation.Rule 2 prevents the most common failure. Without it, the agent can guess between two accounts with similar names.
Common errors
- No record found for a record that exists. The user lacks access, or the name differs from the stored value. Check sharing and field-level security first.
- The wrong record is used. The instructions did not require exactly one match. Add an explicit clarification rule.
- A field comes back empty. The field is not selected in the action's configuration, or the user cannot read it.
- Query Records returns too much or too little. The request was vague. Instruct the agent to confirm filters, such as status or date range, when the user is unclear.
Exercise
A user asks, "What is the billing city for Acme?" Which two standard actions run, in what order, and why?
Show answer
First Identify Record by Name finds the Acme account and returns its record ID. Then Get Record Details uses that ID to read the billing city field. The second action needs the ID that the first one produces.
Exercise
Identify Record by Name finds three accounts called "Northwind". What should your topic instructions make the agent do?
Show answer
Ask the user to clarify which account they mean, instead of choosing one. For example: "If you cannot find exactly one matching record, ask the user to clarify instead of guessing."