# `AshWorkflow.Changes.ConditionalOnSuccess`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/changes/conditional_on_success.ex#L1)

An Ash change that evaluates an automatic step's `on_success` routes to
determine the transition target.

Like `AshWorkflow.Changes.ConditionalTransition`, this evaluates routes
against the record with the action's changes folded in — including any
attributes the action computed — since the whole point of routing on
`on_success` is to branch on what the action produced.

In practice this means evaluating against the changeset with its changes
applied (but not yet persisted): this change is appended after the action's
own changes, so by the time it runs, the action's business logic has
already been folded into the changeset. Routes are evaluated in order. The
first route whose `when` expression matches wins; a route with no `when`
(an unconditional fallback) always matches.

If no route matches, that is a distinct failure rather than a silent no-op:
`AshWorkflow.Errors.NoMatchingRoute` is added to the changeset, which fails
the action and sends it down the step's own error path the same way any
other action failure does. `AshWorkflow.Verifiers.ValidateWorkflow` requires
a step whose `on_success` is not statically exhaustive to declare either
`on_error` or a timeout with `transition_to`, so a step that compiles always
has somewhere for such a record to end up.

Used internally by the AddActions transformer for automatic steps whose
`on_success` needs runtime evaluation (more than one entry, or a `when` on
its single entry). Not intended for direct use.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
