Sub topic 5
Secure data retrieval
This chapter covers the first protective step in the request flow: how the Trust Layer decides which CRM data may reach a prompt. It assumes you know Salesforce objects, fields, and permission sets, and have a general idea of what a prompt is.
What secure data retrieval means
An Agentforce agent often needs record data to answer well. Secure data retrieval is the step that fetches that data. It runs before any masking or model call, and it runs in the context of the user who is talking to the agent.
The key idea is that the agent does not get its own broad view of your org. It sees what the running user could already see. If a user cannot open a field in the UI, that field's value should not appear in the prompt built for them.
Where retrieval happens
Retrieval is triggered by an agent action. An action might look up a case, query a record, or call a flow. The data it returns is then used to build the prompt, a step covered in the grounding chapter.
What gets enforced
The checks reuse standard Salesforce access controls. The table lists the ones that matter most.
| Control | What it limits |
|---|---|
| Object permissions | Which objects the user can read |
| Field-level security | Which fields on a record the user can see |
| Sharing rules and record access | Which individual records the user can open |
Because these are the same controls you already manage, no separate "AI permission model" exists to maintain. Your existing setup is the policy.
A worked example
Suppose a support rep and a finance analyst both ask an agent, "Summarize the account for Acme." The Account has a custom field, Credit_Limit__c.
- The finance analyst has field access, so the field value can be retrieved and included in the prompt.
- The support rep lacks field access, so the value is omitted. The summary is built without it.
The agent is the same, and the question is the same. The prompts differ because the users differ.
Common errors
- Assuming the agent is a super user. Retrieval follows the running user, but some actions can run in a different context, such as a flow or Apex class configured to run in system mode. Check how each action is built. A system-mode action can return data the user could not otherwise see.
- Over-broad permission sets. If users have access to more than they need, the agent can retrieve more than it should. The layer enforces your permissions. It does not correct them.
- Treating retrieval as masking. Retrieval limits what enters the prompt. It does not hide the sensitive values that are allowed in. That job belongs to data masking, a later chapter.
Summary of the step
- The user asks a question.
- The agent triggers an action.
- Salesforce applies the user's object, field, and record access.
- Only permitted data moves on to grounding.
Exercise
A support rep asks an agent for an account summary, and the finance-only field CreditLimit_c is missing from the result. The agent uses a standard retrieval action. Why is the field missing, and what would you check if the field appeared when it should not have?
Show answer
The rep lacks field-level security on CreditLimit_c, and retrieval runs as the user, so the value was left out. If the field appeared when it should not have, check the rep's permission sets and profile for field access. Also check whether the action uses a flow or Apex class running in system mode, which can bypass the user's field access.