Print this page

Visual Workflow-How to create a custom Fault Message

Knowledge Article Number 000181616
When creating a Flow, you might want to create a custom error message that will show up when certain conditions are met (or not met) .

You can do this, by using text templates and the flow Fault Message variable.

We'll use an example to demonstrate how you can use a "Text Template" along with the Flow "Fault Message" merge field.

The Flow that we are creating:

  1. Prompts the user to enter a word.
  2. Searches for Account records that matches your input.
  3. If the Account is found, it returns the ID of the Account and a confirmation screen.
  4. If no Account is found, it goes back to the first screen and displays a custom error message letting the user know that no Accounts were found.
  1. Create our "Screen Element" with a text field where the User can type in the Account name and make this the start screen. (See Adding and Configuring a Screen Element for more information.)
  2. Create a "Lookup Element" that searches for the Accounts where the Account's name, matches the text typed in by the User. In this example the record "Lookup Element" is labeled "AccountSearch". (See Adding and Configuring a Record Lookup Element for more information.) 
  3. Create a "Decision Element". The first output will be: {!AccountSearch} Equals {!$GlobalConstant.True}. The second output will be  {!AccountSearch} Equals {!$GlobalConstant.False}. Configure this element so that if the query returns a value of True (an Account record is found), it moves on to a Screen Element used for confirmation. Now, add if the query returns a value of False, it moves on to an "Assignment Element" (This is described on step number 6). (See Adding and Configuring a Decision Element for more information.)
  4. Create a "Text Template" with the custom error message, i.e "The Account does not exist, please try again". In this example, the template is called {!$Message}. (See Adding and Configuring a Text Template for more information.) 
  5. Create a new "Variable". Place $Flow.FaultMessage as the default value of the "Variable" and set the Input/Output Type to Input & Output. In our example, the "Variable" is labled {!$Error}. (See Adding and Configuring a Variable for more information.)
  6. Now lets create an "Assignment Element" with the following: {!$Error} - equals - {!$Message}. This will replace the Global Variable $Flow.FaultMessage, with your custom error message from step 4. (See Adding and Configuring an Assignment for more information.)
  7. Link your Flow so that your "Assignment Element" is connected to the first screen on your Flow.
  8. Add the {!$Error} merge field to the first "Screen Element". 

When the User executes the Flow, they are asked for an Account name. The Flow then searches for that Account. If the Account is not found, it changes the value of the default "Fault Message" with your custom message and then goes back to the start screen with the error displayed.


promote demote