Sub topic 6
Field Generation templates
This chapter covers the Field Generation template type in Prompt Builder. It assumes you know what objects, records, and fields are, that you can work in Lightning Experience and Setup, and that Einstein generative AI is enabled in your org. It also assumes you have seen the parts of a prompt template: the name, the type, the object, the prompt text, and the model.
What a Field Generation template does
A Field Generation template fills in one field on a record. The prompt reads other data on that same record, sends it to a large language model (LLM), and returns text. The user reviews the text and decides whether to keep it.
Typical uses:
- A short account description built from industry, size, and revenue.
- A "next steps" note on an opportunity.
- A plain-language explanation of a technical case description.
- A product blurb written from several product fields.
The main difference from other types is where the output goes. A Sales Email template produces a message that someone sends. A Record Summary template produces a read-only summary. A Field Generation template produces a value for a specific field. That is why this type is bound to one object and one field.
What you choose when you create one
When you create the template, you set these values.
| Setting | What it controls |
|---|---|
| Template type | Field Generation. This decides the available inputs and where the output can appear. |
| Object | The object whose records supply data, for example Account. |
| Field | The target field that receives the generated text. |
| Prompt | The instructions plus merge fields and other resources. |
| Model | The LLM that runs the prompt. The Einstein Trust Layer still applies (see the Trust Layer chapter). |
The target field must be able to hold text. Plan for a text-style field such as Text Area or Long Text Area. Pick a field whose length limit fits the output you want. If the field accepts 255 characters and your prompt invites a long paragraph, the result will not fit. State a length limit in the prompt itself.
How the user sees it
Field Generation templates work through the record page. In a typical setup, an admin adds the target field to a Lightning record page that uses Dynamic Forms. When a user edits that field, an Einstein option appears next to it. The user selects it and Salesforce:
- Resolves the merge fields with the current record's values.
- Sends the filled-in prompt through the Trust Layer to the model.
- Shows the generated text in the field for review.
The user can edit the text, regenerate it, or discard it. Nothing is final until the user saves the record. This review step is a design feature. Treat the output as a draft.
Writing the prompt
The prompt has three jobs: say what to write, supply the facts, and say what to do when facts are missing. The following example does all three.
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.The elements:
- Instruction. "Write a one-sentence description ... for a sales rep" names the output shape, the length, and the audience.
- Merge fields.
{!$Input:Account.Name}is replaced by the account's name when the prompt runs.$Inputrefers to the record the template is based on, andAccountis the object name. - Missing-data rule. The last line tells the model not to invent a value for an empty field.
Why the missing-data rule matters
A merge field for an empty field resolves to nothing. The model then sees a label with no value, such as "Industry:". Without guidance, models often fill the gap with a plausible guess. A guessed industry written into a record is worse than a blank one, because people trust record data. An explicit instruction reduces the risk but does not remove it, so the review step stays necessary.
Grounding beyond the record's own fields
Grounding means giving the model real data to work from. For Field Generation, the base object supplies most of it, but you can reach further:
- Parent fields through relationships. On a Contact template, a path such as
{!$Input:Contact.Account.Name}pulls the parent account's name. - Related lists. You can insert related records, such as an account's recent opportunities. Use these with care, because a long list makes the prompt large and may push out the instructions that matter.
- Flows and Apex. For data that is not a direct field or relationship, a flow or an Apex method can compute a value and return it for the prompt to use.
Prompt Builder's resource picker lists what is available for the object and inserts the right syntax. Use it instead of typing paths by hand. A mistyped merge field is a common error, and it can fail silently or show up as an unresolved value in the prompt.
Keep the prompt focused
Include only the fields that the target field needs. Extra fields add cost and noise, and they widen the amount of record data sent to the model. If a field is not relevant to the output, leave it out.
A second example: a field that depends on text
Field Generation works well for rewriting or condensing text that already exists on the record. Here is a prompt that fills a Case "customer-friendly explanation" field.
Rewrite the technical note below as a short, plain-language explanation for the customer.
Use no more than 60 words. Do not mention internal system names. Do not promise a resolution date.
Case subject: {!$Input:Case.Subject}
Technical note: {!$Input:Case.Description}
If the technical note is empty, reply with exactly: No explanation available.Notice what the prompt controls:
- A word limit that fits the field.
- Negative constraints for content that would be harmful to publish, such as internal names and promised dates.
- A fixed reply for the empty case, which is easier to detect than a free-form apology.
Common errors and how to diagnose them
| Symptom | Likely cause | What to do |
|---|---|---|
| The output mentions facts that are not in the record | The prompt invites creativity, or a value was empty | Add "do not invent details" and an empty-value rule |
| Output is cut off or rejected on save | Field length is shorter than the output | Add a length limit to the prompt, or use a longer field |
| The Einstein option does not appear | The template is not active, or the field is not on a supported record page | Activate the template and check the page layout |
| Merge field shows as raw text or blank in preview | Wrong object name or path | Reinsert the field with the resource picker |
| Results differ between users | Users have different field access | Check field-level security, since a user only provides data they can see |
| Tone varies from run to run | The prompt gives no style guidance | Specify tone and audience, and give a format |
Because the model is not deterministic, the same record can give slightly different text on different runs. Write prompts so that any reasonable variation is acceptable. If the text must be exact, a formula field is a better tool than a prompt.
Choosing Field Generation over other types
Use Field Generation when the result belongs in a field and one record supplies the facts. Consider another type when:
- The output is an email. Use Sales Email.
- The output is a read-only overview, shown on demand. Use Record Summary.
- The inputs come from more than one record or from free text. Use Flex.
The next chapters cover these types. The chapter on choosing a type puts them side by side.
Testing before you activate
Use the preview in Prompt Builder before you activate. Pick a real record, check that the resolved prompt contains the values you expect, and read the generated text. Then test with an edge-case record: one with empty fields, one with unusually long text, and one with special characters. Most failures show up in those records and not in your typical sample. Previewing and versioning are covered in more detail in a later chapter.
Summary
- A Field Generation template writes text into one field on a record, using data from that same record.
- It is bound to an object and a target field, and it surfaces as an Einstein option on the record page.
- Merge fields such as
{!$Input:Account.Name}supply the data. Related records, flows, and Apex can supply more. - Good prompts state the output shape, give a length limit, and tell the model what to do with missing data.
- The user always reviews the text before saving.
Exercise
A Field Generation template writes a "Description" for each Account. Some accounts have no Industry value, and reps report that a few descriptions name an industry that is wrong. Which two changes to the prompt would you make first, and why?
Show answer
Add an explicit rule such as "If a value is empty, leave it out instead of guessing", so an empty Industry is not filled with a plausible guess. Also add a constraint such as "Use only the information given" and keep the prompt limited to fields that exist on the record. The first change removes the cause (an empty merge field with no guidance). The second limits the model's room to invent facts. Because the model's output can still vary, users should keep reviewing the text before saving.
Exercise
You build a Field Generation template for a Text Area field that holds 255 characters. In testing, the generated text is sometimes longer and fails to save. Name two ways to fix this.
Show answer
Add a length limit to the prompt, such as "Use no more than 40 words" or "Keep it under 200 characters". Or change the target to a longer field type, such as a Long Text Area, if the business case allows it. Stating the limit in the prompt is usually the first step, because the model cannot see the field's length unless you tell it.