Sub topic 9
Creating and updating records
This chapter covers the standard actions that write data: Create Record and Update Record. It assumes you can add a standard action to a topic in Agentforce Builder, and that you know how topic instructions, action inputs, and slot filling work. It also assumes you know basic Salesforce objects, fields, and permission sets.
Why write actions need more care
Lookup and summary actions only read data. A wrong answer there is a bad response the user can see and correct. A write action changes the org. If the agent picks the wrong record, fills a field with a guessed value, or creates a duplicate, the bad data stays until someone finds it.
Most of your work with these actions is therefore not configuration. It is deciding when the agent may write, what it must confirm first, and what it must check before it acts.
The two actions
| Action | What it does | Typical inputs |
|---|---|---|
| Create Record | Inserts a new record of an object | The object, plus values for the fields you want set |
| Update Record | Changes fields on an existing record | The record to change, plus new values for the fields |
Treat the input names above as a model, not a specification. The exact inputs and labels can differ between releases, so open the action in Builder and read its input panel. Each input has a name, a description, and a setting for whether the agent collects it from the user or takes it from a variable.
Both actions run as the user the agent acts for. Object permissions, field-level security, and sharing apply, so a write the user could not do in the normal UI will fail here too. Chapter 13 covers this in detail.
Update Record needs a record first
Update Record changes a specific record, so the agent must know which one. That usually means a lookup runs first. The reliable sequence is:
- Find the record, for example with Identify Record by Name or Query Records.
- Keep the result, which includes the record ID.
- Pass that result to Update Record.
If the agent skips step 1, it has nothing valid to pass as the record. It may ask the user for an ID, which users rarely know, or it may produce a bad value. Your topic instructions should state the order explicitly, because the agent does not infer it reliably.
The sequence below shows a well-behaved update, including the confirmation step.
Writing instructions that make updates safe
The agent decides when to call actions based on the topic's instructions and the action descriptions. For write actions, the instructions should cover four things: which lookup comes first, what the agent confirms, what happens on ambiguity, and what the agent may not change.
Topic: Account Support
Classification description:
Handle questions about a customer's account, such as looking up an account, summarizing it, or updating basic fields.
Instructions:
1. When the user names an account, first find the account record, then use the result for any later step.
2. Before updating a record, restate the field and the new value and ask the user to confirm.
3. Only update the Phone, Website, and Description fields. If the user asks to change any other field, explain that you cannot do that.
4. If you cannot find exactly one matching record, ask the user to clarify instead of guessing.
5. After an update, tell the user what changed. If the action returns an error, report the error and do not say the update succeeded.Instruction 3 deserves attention. The Update Record action can in principle write any field the user can edit. A topic instruction limits what the agent will attempt. It does not limit what the platform allows, so treat it as guidance for behavior and not as a security boundary.
Limiting what the agent can write
You have three layers of control. Use them together.
- Topic instructions tell the agent what it should and should not change. They are guidance, and the model can still deviate.
- Action input configuration controls which inputs the agent fills in and which values are fixed. Where you can fix a value or restrict an input, that is stronger than an instruction.
- Permissions are the enforced layer. Field-level security and object permissions on the running user decide what can actually be written.
If a field must never be changed through the agent, remove edit access from the permission set the agent's user relies on. Do not depend on an instruction alone.
Create Record in practice
Creating a record means the agent must collect enough values to satisfy the object's required fields and validation rules. Slot filling helps here: if required inputs are missing, the agent asks the user for them. It cannot ask for what it does not know is required, so list the required values in the instructions.
Topic: Case Intake
Instructions:
1. To log a new case, collect the subject, a short description, and the priority from the user.
2. Find the account first and attach the case to it. If you cannot find exactly one account, ask the user to clarify.
3. Before creating the case, read the values back and ask the user to confirm.
4. After creating the case, share the case number if the action returns one.Common creation problems:
- Duplicates. If the user repeats a request, or a retry follows an unclear failure, the agent may create the same record twice. Instruct the agent to check for an existing record before creating, with a query, when duplicates matter.
- Missing relationship. A contact or case with no parent account is often valid in the data model but useless to the business. Require the lookup step in the instructions.
- Validation rule failures. The platform rejects the record and returns an error. The agent should relay it, and your instructions should tell it not to claim success.
- Picklist values. The agent may offer a value that is not an active picklist value. List the allowed values in the instructions or the input description.
Failure modes for write actions
| Symptom | Likely cause | Fix |
|---|---|---|
| Wrong record updated | Lookup returned several matches and the agent picked one | Require exactly one match, otherwise ask the user |
| Update runs without confirmation | No confirmation step in the instructions | Add an explicit confirm-before-write instruction |
| Agent says it updated but nothing changed | The action returned an error and the agent glossed over it | Instruct the agent to report errors and check the action output in testing |
| Update fails for one user but not another | Field-level security or sharing differs between the users | Compare the permission sets of the users |
| Value stored in wrong format | Ambiguous input description, such as a date | Describe the expected format in the input description |
Verifying behavior
Test write actions in the Builder's conversation preview, with the plan or action log visible. For each test, check three things: which actions ran and in what order, what values were passed into the write action, and what the action returned. Then open the actual record to confirm the change.
Run these cases at least once:
- A clear request with one matching record, which should confirm and then write.
- A request with two matching records, which should ask for clarification and not write.
- A request to change a field you excluded, which should be declined.
- A user who has read-only access to the object, which should fail and report it honestly.
- A user who says no at the confirmation step, which should not write.
Test in a sandbox. A mistake in a preview conversation is a real write to real data.
When the standard actions are not enough
Standard Create Record and Update Record work on single records with direct field values. If you need to change several related records together, apply calculated values, or enforce business logic beyond validation rules, a custom action built with Flow or Apex is a better fit. Chapter 15 covers that decision.
Exercise
A user says, "Update the Globex account's website to globex.example." Your topic has Identify Record by Name and Update Record. Query shows two accounts named Globex. List the behavior you want from the agent, and name the instruction that produces it.
Show answer
The agent should not call Update Record. It should tell the user that more than one account matches and ask which one they mean. Only after the user picks one, and after the agent restates the field and value and gets a confirmation, should it run Update Record. The instruction that produces this is "If you cannot find exactly one matching record, ask the user to clarify instead of guessing", together with "Before updating a record, restate the field and the new value and ask the user to confirm."
Exercise
You have told an agent in its topic instructions to change only Phone and Website. A user without edit access to Website asks it to update Website. What happens, and which layer actually stops the write?
Show answer
The instruction allows the attempt, so the agent runs Update Record. The write fails because the action runs as the user and field-level security denies edit access to Website. The permission layer stops it. The agent should report the error and not claim success.