Sub topic 3
Debug options: input values, rollback, and running as another user
This chapter covers the controls that decide what data a debug run uses, whether the run changes your org, and which user the flow runs as. It assumes you can already start a debug run from Flow Builder and read the element-by-element results. It also assumes you know your flow's type and how it starts. Use a sandbox or Developer Edition org for the examples. Labels in the debug panel change between releases, so match the ideas here to the wording in your org.
What a debug run actually does
A debug run executes a real flow interview against your org's data and metadata. This has three consequences:
- Without rollback mode, a Create Records, Update Records, or Delete Records element commits real changes.
- Elements that act outside the database, such as emails or callouts, have real effects.
- The flow runs with the permissions and context of a specific user.
Each debug option controls one of these three things.
Supplying input values
The input you can set depends on how the flow starts.
Autolaunched and screen flows
Any variable with Available for input selected appears in the debug panel. You can set a value for each one before you run. Typical inputs are:
- A text, number, date, or Boolean value.
- A record variable, such as an Account passed in from a button.
- A collection of values or records.
If you leave an input empty, the flow sees null for that variable. Leaving inputs empty is a useful test in its own right. Flows that are called from Apex, from buttons, or from other flows often receive missing values in production.
A good set of test inputs for a discount flow covers the happy path, the boundaries, and the failure cases. For example:
Run 1: inputAmount = 1500 (normal case)
Run 2: inputAmount = 0 (boundary)
Run 3: inputAmount = -50 (invalid value)
Run 4: inputAmount = (empty) (missing value)Compare each run with what you expected, not just with whether the run finished. A run that finishes without errors can still return the wrong output. Check the output variables in the results pane after each run.
Record-triggered flows
For a record-triggered flow, you choose a record from the object the flow is built on. The debugger then uses that record as $Record. For flows that fire on update, you can also edit field values in the debug panel to simulate the change. You can see how the flow behaves when StageName moves from Prospecting to Closed Won, for example, without editing the record in the org first.
Depending on your release, the panel offers a few more controls:
- A choice of the triggering event: record created, updated, or deleted. Pick the one that matches the way the flow starts.
- For flows that use scheduled paths, a way to run the scheduled path directly instead of waiting for the scheduled time.
- A Skip start condition requirements checkbox, which is covered below.
The record you pick is real. If the flow updates it and you are not in rollback mode, the update is saved.
Skip start condition requirements
A record-triggered flow only runs when the record meets its entry conditions. If your chosen record does not meet them, the debug run may finish at once without running any elements. That result is correct behavior, not a bug, and it is a common source of confusion.
You have two ways to proceed:
- Choose or edit a record that meets the entry conditions. This tests the flow the way it will run in production.
- Select Skip start condition requirements. The debugger then runs the flow body whatever the conditions say.
Prefer the first option when you can. Skipping the conditions hides mistakes in the entry criteria. Use the second option only when you want to test the logic after the Start element in isolation.
Rollback mode
Rollback mode runs the whole interview and then undoes the database changes it made. In the debug panel it appears as an option to run the flow in rollback mode.
Use it when:
- You are debugging against a sandbox that holds data people rely on.
- A flow deletes records or sends bulk updates.
- You want to run the same case many times with identical starting data.
What rollback does not undo
Rollback only reverses database changes. It cannot undo effects that have already left the transaction. Assume these are not reversed:
- Emails sent by a Send Email action.
- Callouts to external systems, including HTTP callouts and external services.
- Platform events that have been published, since subscribers may already have processed them.
- Anything an Apex action does outside the database.
Some elements behave differently in rollback mode. In particular, the debugger may warn you when a flow contains a Pause element or an action that cannot be rolled back. Read any warning before you continue.
Rollback and the results you see
Inside the run, the flow behaves as if the changes were saved. A Get Records element after an Update Records element sees the updated values. The undo happens only at the end. That is what you want, because the logic you are testing sees consistent data.
The flip side is that you cannot check the saved result in the org after a rolled-back run. The record looks untouched. Use the results pane to inspect values during the run instead of opening the record afterward.
When you need to see the real committed outcome, run once without rollback in a sandbox, on a record you can discard.
| Setting | Database changes | Emails and callouts | Best for |
|---|---|---|---|
| Rollback mode on | Undone at the end | Still happen | Repeated runs on shared sandbox data |
| Rollback mode off | Saved | Happen | Confirming the final committed result on disposable data |
Running as another user
By default the flow runs as you. That is a problem if you are an administrator with broad access, because the flow may work for you and fail for the people who use it.
The Run flow as another user option lets you choose a user for the run. It appears only if your own access permits it. If you cannot see it, ask your administrator rather than looking for a workaround.
What changes when you switch users
The user affects what the flow can do in two ways:
- Context values.
$Userfields such as the user's Id, role, and profile now describe the chosen user. Formulas and decisions that read$User.Idor$User.ProfileIdproduce different results. - Permissions. Object permissions, field-level security, and record sharing apply to the chosen user, but only when the flow runs in user context.
The second point depends on how the flow runs. Record-triggered flows generally run in system context, so they ignore the user's object and field permissions. Screen flows launched by a user run in the user's context by default. Autolaunched flows have a run mode in the flow settings, so check yours. If the run mode is system context, switching users changes $User values but not permission checks.
So choose the user based on what you want to find out:
- To check that a screen flow works for a sales rep, run as a user with the Sales profile and no extra permission sets.
- To check that a formula based on role routes correctly, run as users in each role.
- To confirm a system-context flow can update a field that users cannot edit, run as a restricted user and confirm it still works.
A worked example
A screen flow lets users update the Discount_Reason__c field on an Opportunity. You run it as yourself and it works. A sales rep reports a failure at the Update Records element. The steps to reproduce are:
- Open the flow and select Debug.
- Select Run flow as another user and choose the rep's user record.
- Run the flow in rollback mode, with an Opportunity the rep owns.
- Read the failing element in the results pane.
The results pane shows an error such as insufficient access to the field. The cause is that the rep's profile has no edit access to Discount_Reason__c. You can grant the access, change the flow to run in system context, or change the screen so it does not offer the field. The right choice depends on whether the rep should be allowed to change this field. The debugger found the problem. It did not decide the fix.
Combining options
The options work together, and some combinations are more useful than others.
- Rollback plus another user is the default for most debugging. It tests real permissions without changing data.
- Inputs at the boundaries plus rollback lets you run many edge cases in a row on the same record.
- Skip start conditions plus rollback is useful for isolating one branch of a large flow, because you do not have to build a matching record first.
A pattern that works well is to change one option at a time. If a run behaves differently as another user, you know the cause is the user. If you changed the input, the user, and the rollback setting all at once, you would not know which one mattered.
Common mistakes
- Reading an empty run as a failure. The record did not meet the entry conditions. Check this first on any record-triggered flow.
- Trusting a debug run as a permission test. If you ran as yourself, or the flow is in system context, a pass says little about your users.
- Assuming rollback undoes everything. Emails, callouts, and published platform events remain.
- Forgetting the data is real. A run without rollback changes the chosen record. Pick a disposable one.
- Testing only the happy path. Empty and out-of-range inputs expose most of the flow's weak spots.
Exercises
Exercise
A record-triggered flow on Opportunity only runs when the stage is Closed Won. You select an Opportunity in Prospecting and debug, and the run ends immediately with no elements executed. Give two ways to get the flow body to run, and say which one you should prefer.
Show answer
Edit the record values in the debug panel (or choose a different record) so the stage is Closed Won, or select Skip start condition requirements. Prefer the first, because it tests the flow the way it runs in production, including the entry conditions. Skipping the conditions can hide a mistake in them.
Exercise
You debug a flow in rollback mode. It updates an Account and then sends an email through a Send Email action. After the run, the Account looks unchanged. Was the email also undone? Explain.
Show answer
No. Rollback mode reverses database changes only, so the Account update was undone. The email had already left the transaction, so the recipient still receives it. Run flows with emails only in a sandbox or with test recipients.
Exercise
A record-triggered flow runs in system context and updates a field that sales reps cannot edit. You debug it as a sales rep using Run flow as another user, and it succeeds. A colleague says this proves reps have access to the field. Is that correct?
Show answer
No. A system-context flow does not apply the user's field-level security, so the success says nothing about the rep's own access. The user switch changed only values such as $User. To test the rep's actual permissions, use a flow that runs in user context, such as a screen flow.