Sub topic 6
Field Generation templates
This chapter assumes you know Salesforce objects, records and fields, can work in Setup and Lightning App Builder, and have read the earlier chapters on template anatomy and grounding. Einstein generative AI must be enabled in the org.
What a Field Generation template does
A Field Generation template fills in one text field on a record. The prompt runs against a single record of one object, such as an Account. The model's response is offered to the user as the value of a field on that record.
Sales Email templates produce a draft message. Field Generation templates produce stored data. The output is usually short and meant to be kept, for example an account description, a short case title or a one-line opportunity note.
The working model
A Field Generation template has three parts:
- An object. You choose the object the template is based on. This sets the record the merge fields read from.
- A target field. You choose the field that receives the output. It must be a text-type field on that object.
- A prompt. The instructions, with merge fields that pull values from the record.
The flow at run time is shown below.
The user stays in control. The generated text is a suggestion until the user saves it.
Writing the prompt
Ground the prompt in fields from the same record. This example builds an account description from three fields:
Using the information below, write a one-sentence description of this account for a sales rep.
Account name: {!$Input:Account.Name}
Industry: {!$Input:Account.Industry}
Annual revenue: {!$Input:Account.AnnualRevenue}
If a value is empty, leave it out instead of guessing.Three habits in this prompt are worth copying:
- State the audience and the length. "One sentence for a sales rep" limits both tone and size. A field has limited space, so an unbounded answer may not fit.
- Pass real values. Each
{!$Input:Account.…}merge field is replaced with data from the record before the model sees the prompt. - Say what to do with missing data. Without the last line, the model may invent an industry or revenue figure to fill the gap.
The Account part of each merge field matches the object you chose for the template. A merge field for a different object is a common source of empty values.
Where the output appears
Users see the result on the record page. An admin adds the template to the target field through the record's Lightning page, using Dynamic Forms. After that, the field on the record shows a way to generate a value. The template must be active before it can be attached.
If the field never shows the generate option, check these things in order:
- The template is active and its object matches the record page's object.
- The record page uses Dynamic Forms, and the field is placed as an individual field component.
- The field is configured to use the template.
- The user has access to the field and to the generative AI feature.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Output mentions facts that are not on the record | The prompt has no rule for missing values | Add "leave it out instead of guessing" and a length limit |
| Merge field text appears blank in the preview | The preview record has no value in that field | Preview with a record that has the data, and keep the empty-value rule |
| Output is too long for the field | No length instruction | Give a word or sentence limit that is below the field limit |
| Template is missing from the field setup | It is still a draft, or its object differs from the page's object | Activate the version and check the object |
Testing before you attach it
Use the preview in Prompt Builder. Pick a real record, then check two things: the resolved prompt (are the merge fields filled in?) and the response. Try one record with complete data and one with gaps. A template that behaves well on both is ready to activate.
Exercise
A Field Generation template for the Account object returns "A technology company with $0 in revenue" for accounts where Annual Revenue is blank. What change to the prompt fixes this, and why?
Show answer
Add an instruction such as "If a value is empty, leave it out instead of guessing." The merge field resolves to an empty value, and without a rule the model fills the gap on its own. The instruction tells it to omit the missing detail.