How to use Custom Error Element in Flow 📊| Winter '24 Update


Custom Error Element

Winter'24 release updates are here and we will cover our first update in this blog.

We have a new element in flow which is CUSTOM ERROR ELEMENT.

Now, we can use the new Custom Error Message element to create targeted error messages for your end users to explain what went wrong or how to correct it.
The error messages display in a window on the overall record page or as an inline error on a specific field.
The associated record change is rolled back. Error messages can be created for before-save and after-save flows.

By this you know that custom error messages are for record-triggered flows.

Before moving forward you will need a winter'24 org to play around and for that you can go to the following link -

Now, if you have a winter'24 ready org. Let's start with our example.

Use Case - Create a record trigger flow for contact. Create a case for the same contact. Show a custom error message if the title of that contact is empty and also make sure that if the error occurs then the created case is rolled back.

Here is how our flow will look -

Step 1 - Create a record triggered flow which will trigger whenever a contact will be created.

Step 2 - Take a create record element and create a case with ContactId as the $Record's contact Id.

Step 3 - Take a decision element to check if the title of the triggered contact is empty.

Step 4 - If yes, Take a custom error element and let's try showing custom error on the record window and then on a specific field.

When you take a custom error element, this is how it would look -

We have following options here -

  • Label - Element's Label Name.
  • Api Name - Element's Api Name.
  • Description - Add a small description about the element.
  • Set error message 1 details - With this option you can set where do you wish to show the error message.
You have 2 options here -

  • In a window on a record page - With this option you can show the error message on the record page window. After you select this option, In the Error Message text area given below this option type your error message. Here is an example -

Now, Let's save our flow and test it by creating a new contact.

I have added First Name and Last Name and left the title field blank. Now, Let's try saving this contact.

This is how you get a custom error message on the window of a record page.
"We hit a snag." Then it shows the error message that we have added in our element in flow.

Now, Let's try the second option of displaying the error.
  • As an inline error on a field - With this option you can show error message on a particular field. When we select this option, we get to select a field to the error message at -

I have selected "Title" field from the picklist and in error message written the same message as above.
Let's save our flow again and see how the error displays now.

Here you can see in the error we have a hyperlink to the field that we chose in the flow. This hyperlink focuses on the field that is mentioned when you click on it.

Also, look at the title field, The error message that we added in the element is showing underneath the title field.

These two are the options of displaying the custom error message to your user.

With custom message if error occurs then the previous action will be rolled back and that's why we have added a create record element to create a case but it won't be created and will be rolled back if the error occurs.

Hope you found this article useful. It is a very useful feature from the flow updates.

Don't stop here, Do try this out by yourself to understand and explore it better.

If you like to learn with a video tutorial instead, Do checkout the below video -

If you have any question please leave a comment below.

If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Let's learn and grow together.
Love and Peace!

Post a Comment