Sub topic 3
Debug options: input values, rollback, and running as another user
This chapter assumes you can build a basic flow, use variables, and open the Debug panel in Flow Builder. It covers the options you set before a debug run so that the run matches the conditions you want to test.
What the debug options control
When you select Debug in Flow Builder, a panel opens before the run starts. The options in this panel decide three things: what data the flow starts with, whether the run changes real data, and whose permissions apply.
Which options appear depends on the flow type. A record-triggered flow asks for a record. A screen flow or autolaunched flow asks for values for its input variables.
| Option | What it does | Typical use |
|---|---|---|
| Input values | Supplies the record or variable values the flow starts with | Reproduce a failing case |
| Run flow in rollback mode | Runs the flow, then undoes its database changes | Test safely in an org with real data |
| Show details of what's executed | Lists each element and its result | Trace decisions and assignments |
| Run as another user | Runs with a different user's permissions | Check access problems |
| Require confirmation on high-volume operations | Pauses before large operations | Avoid unexpected bulk changes |
The exact labels can vary by release, so check the panel in your org.
Supplying input values
For a record-triggered flow, you choose an existing record to act as the triggering record. For an update trigger, you can also set field values on that record, which lets you simulate the change that fires the flow. For example, you can set StageName to Closed Won to test a flow that fires only on that stage.
For an autolaunched or screen flow, you enter a value for each input variable. Variables of type record, collection, or text each need an appropriate value. A variable you leave empty is null, and a null value is a common cause of failures in the elements that use it.
The debugger remembers your last values, so you can rerun a case after changing the flow.
Rollback mode
In rollback mode, the flow runs normally and the debugger shows every create, update, and delete. At the end, Salesforce rolls the changes back, so no records are saved.
Use rollback mode when you debug in an org that has real or shared data. Without it, a debug run makes real changes. A flow that creates tasks or sends emails will do so for real.
Keep two limits in mind:
- Rollback undoes database changes only. It does not undo actions that leave the transaction, such as some callouts.
- Records created during a rolled-back run do not exist afterward, so you cannot inspect them in the org. Read the debug output instead.
Running as another user
By default, the debug run uses your own permissions. A flow that works for you as an administrator can fail for a standard user who lacks access to an object or field. The Run as another user option lets you choose a user and run the flow with that user's profile and permission sets.
This helps when a user reports an error that you cannot reproduce. If the flow runs in user context, the other user's object, field, and record access applies. If the flow is set to run in system context, record sharing is skipped, so results can differ from what the user's access suggests.
Steps for an access problem:
- Open the flow and select Debug.
- Choose the failing user in Run as another user.
- Enter the same input values the user had.
- Turn on rollback mode and run.
- Find the element that fails and read its error.
Common mistakes
- Testing with the wrong record. The flow's entry conditions may not match the record you picked, so the flow ends without running any elements. Check the conditions first.
- Forgetting rollback. This leaves test data behind.
- Assuming your own access applies. Reproduce user problems with Run as another user.
- Treating a clean debug run as proof. A debug run tests one case. Cover other cases with flow tests, covered in a later chapter.
Exercise
A user reports that your record-triggered flow fails with an insufficient access error, but it runs fine for you. The org has live data. Which debug options do you set, and why?
Show answer
Select Run as another user and choose the reporting user, so the flow runs with that user's permissions. Enter the same triggering record and field values the user had. Turn on rollback mode so the run does not save changes to live data. Then find the failing element in the results.