Skip to content

Instantly share code, notes, and snippets.

@julio73
Created August 5, 2020 14:12
Show Gist options
  • Save julio73/466c957d632e5bee63dc8032c0c220e4 to your computer and use it in GitHub Desktop.
Save julio73/466c957d632e5bee63dc8032c0c220e4 to your computer and use it in GitHub Desktop.
10 Best practices for designing flows in Salesforce

10 Best practices for designing flows in Salesforce

  1. Write each step of the flow in pseudocode before attempting to implement the flow itself. It's easier to change things at this stage and breakdown the flow into chunks and possible subflows.

  2. Identify fixed (or hardcoded) values and turn them into inputs for a process builder (if run-as a background process) or into inputs passed by apex class (if run-as a user facing flow). This makes the testing process easier since you can pass your own test accounts IDs and other random values for debugging.

  3. Validate user inputs before passing them to the flow but also confirm all required inputs available before launching the flow. This is an early detection process for misconfigured flows or missing objects.

  4. Put all DML fetch actions to retrieve necessary objects at the beginning of the flow. This helps validate that the flow will be able to proceed smoothly.

  5. If creating new objects during the flow, use dedicated subflows that receive the necessary inputs and handle the object creation and the fields assignments. This reduces the overhead in the parent flow and makes the parent flow more readable.

  6. Use a string variable to track where you are in the flow by appending the name of the next step before reaching the next step. When an error happen, look for this string in the logs or the email report to quickly assess how far the error occurred as well as which branches were involved.

  7. Configure and link the fault connectors for any elements that can fault and link it to a common send error email action to notify support (for background flows) or link to an error screen with appropriate messaging (for a user facing flow).

  8. Save as you go then use the run and debug function to provide example input to see each scenario execute as expected. By testing early and testing often, you maintain a working flow that you can restore and branch off from to test other scenarios.

  9. Try to align similar elements vertically and have your flow run from left to right and top to bottom. The flow should almost read like a sentence or a paragraph. Don't be afraid to use explicit names for the elements to describe what they do.

  10. Minutely document the whole process as you go with text, pseudocode, pictures, use cases, known issues, etc. This will come in handy when faced with new design decisions or while navigating error reports or generally discussing the flow with others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment