Sub topic 2
Handling Errors with Fault Paths
Assume you can build flows, identify Salesforce records and fields, and read basic debug output. A fault path is an alternate connector that runs when an element fails. Use fault paths on elements that can fail, such as Create Records, Update Records, Get Records, and actions.
Handling Errors with Fault Paths
Connect the fault path to an error-handling element. Common choices include creating an error record, sending an administrator email, or posting a notification. Capture the original message with $Flow.FaultMessage.
An error occurred in the flow: {!$Flow.FaultMessage}
Flow run time: {!$Flow.CurrentDateTime}
Record Id: {!$Record.Id}$Record.Id is available in record-triggered flows. For other flow types, use the relevant input variable instead. Store useful context, such as the flow name, record ID, user, and failing operation.
A fault path should have a safe, simple design. Avoid adding another operation that is likely to fail. If the error must remain visible to the user, let the flow fail after recording the diagnostic information, when that behavior fits the process.
Tracing Flow Execution with Debug Logs
Flow Builder’s Debug option runs an interview with selected inputs. Review the result for each element:
- The values entering the element.
- The records returned or changed.
- The decision outcome.
- The first element that reports an error.
- The fault message and error details.
Debug logs provide a second view. Add a trace flag for the user who starts the transaction, reproduce the problem, and inspect the log for FLOW_START_INTERVIEW, element execution, database operations, and FLOW_END_INTERVIEW. Start with the first failure, rather than the final cascading error.
Creating and Running Flow Tests
Use the Tests tab in Flow Builder to create a test for a record-triggered flow. Define the triggering record and field changes, then add assertions for the expected result, such as a created Task or updated field. Run the test against the flow version you intend to activate.
Include a success test, a validation or fault case, and a bulk-oriented test strategy. If a test fails, compare its inputs with a Debug run and inspect the related log.
Exercise
What should a fault path capture before notifying an administrator?
Show answer
Capture $Flow.FaultMessage and enough context to identify the flow, transaction, user, and affected record.