Sub topic 7
Grounding prompts in CRM data
Dynamic grounding is the step where Salesforce adds real CRM data to a prompt before the prompt goes anywhere else. This chapter assumes you know Salesforce objects, fields, and user permissions, and that you have read the chapter on secure data retrieval. Grounding comes right after retrieval. Data masking and prompt defense come after it.
What grounding does
An LLM knows nothing about your customers. A prompt that says "Summarize this case" gives it nothing to summarize. Grounding fills that gap. The prompt template contains merge fields and references to related data. At run time, Salesforce resolves them with records the running user can access, and the result is the grounded prompt.
"Dynamic" means the data is read when the request happens, not copied into a model beforehand. The model is not trained on your records. It sees them only inside that one prompt.
Where the data comes from
A prompt template can pull from several sources:
- Merge fields on the record, such as
{!$Input:Case.Subject}. - Related lists and child records, such as case comments.
- Flows that return computed values.
- Apex that returns data the template cannot reach directly.
- Data Cloud, when it is connected and configured.
Each source adds text to the prompt. More context usually gives better answers, but it also means more data leaves the Salesforce boundary. Ground only on what the task needs.
The grounding sequence
A worked example
Suppose a template is written like this:
Summarize the case below for a support manager.
Case subject: {!$Input:Case.Subject}
Contact: {!$Input:Case.Contact.Name}
Latest comment: {!$Input:Case.Latest_Comment__c}For a user who can read all three fields, the grounded prompt contains the real subject, contact name, and comment. For a user who cannot read Latest_Comment__c, that value is not available to the prompt. The model then sees less data, and the summary may be thinner. This is correct behavior, because the agent should not reveal what the user could not see.
Common errors
- Assuming grounding checks relevance. Grounding adds whatever the template references. It does not judge whether a field is sensitive or useful.
- Grounding on too much. Adding every field "just in case" widens exposure and can bury the useful facts.
- Blaming the model for gaps. If an answer is missing a fact, check whether the running user can read the field and whether the template references it.
- Poor data quality. Stale or wrong CRM values produce grounded prompts that are stale or wrong. The model repeats them confidently.
- Treating grounding as protection. Grounding respects permissions, but it does not hide sensitive values. Masking is a separate step.
Exercise
A user reports that an agent's case summary never mentions the latest comment, though admins see it. Name two things to check in the grounding step.
Show answer
First, check whether the running user has read access to the comment field and to the record that holds it, since grounding applies that user's permissions. Second, check that the prompt template actually references the comment field or related record. A missing reference or missing access would each leave the data out of the grounded prompt.