Custom Error Element in Record Triggered Flow

Custom Error Element in Record Triggered Flow

At times, managing errors within Salesforce Flows can pose challenges that impact the team’s overall efficiency.

We usually use the addError() method in Trigger to show an error on the screen.

With winter’24 release you can now capture errors using the Custom Error element in Salesforce.

In this blog, we will explore how to utilize a Custom Error Element in Salesforce Record Triggered Flow with an example.

Custom Error Element :

  • Salesforce introduced a new feature of Custom Error Element in Salesforce Record Triggered Flow to be available from the Winter ’24 Release.
  • We can use this feature in both Lightning Experience and Salesforce Classic for Developer, Essential, Professional, Enterprise, Performance and Unlimited versions of Salesforce.
  • We can display the error message in a window or show an inline message on the specific field as needed.

It is important to note that currently, this feature is not generally available. To get your hands dirty use the Winter’24 pre-release org.

Business-Scenario:

To complete the case, it’s necessary to include a Resolution Comment. If the custom field ‘Resolution Comment’ is empty, an error message should be shown to the user

Pre-requisite:

  • We have created a new custom field, ‘Resolution Comment’ that allows you to add comments when closing the Case.
  • Create an Email Template with the Case as a Related Entity as shown below:

 

 

  • Go to Support Settings from Setup to enable the ‘Show Closed Statuses in Case Status field’, as we want a ‘Closed’ value in the Status picklist of the Case object.
  • Get Record Element: To fetch the Email Template with Developer Name ‘Case_Closure_1695315211444’ this element is used.
  • Email Template ID is {!Case_Closure_Email_Template.Id}
  • Set Log Email on Send as TRUE
  • Recipient ID is the Case Contact ID which is {!$Record.ContactId}
  • Related Record ID is the Case Id {!$Record.Id}Add Email Action

You can also refer Record-Triggered flow blog to create the above flow.

Following are the additions to be done in the Record-Triggered flow which was created in the Pre-requisite part to add the Custom Error Element.

Add Decision Element: The Decision Element checks whether the Resolution_Comment__c is Null or not.

 

Decision Element

 

Custom Error element on Null Loop:

We have two options to show the Error message:

  1. In a window on a record page
  2. As an inline error on a field

Select the first option and add the error message ‘The Field Resolution comment is empty please provide the comment to close the Case.’

Want To Learn Salesforce Flows? Checkout our Salesforce Flow Course

 

Custom error Element

Save and Activate the flow. Let’s take a look at the Actual flow!

Custom Error Element in Salesforce Record Triggered Flow

 

This is how the error message appears in a window.

 

Custom Error in a window

 

To Show an inline error message on the field, Edit the flow and Add an inline error message as ‘Please provide the comment to close the Case’. Click on the Save buttonย to Save the new version and then Activate the flow.

Custom Error Element in Salesforce Record Triggered Flow

 

This is how the inline error appears on the Resolution Comment field.

 

Custom Error Element in Salesforce Record Triggered Flow

 

Here are some use cases where Custom Error Elements can be used:

  • Custom Error Elements can verify if all necessary fields are filled out, eliminating the need for creating separate validation rules. This can be achieved within the Record-Triggered flow.
  • They help prevent the accidental deletion of important records by providing error checks before allowing deletion.
  • Custom Error Elements can check if the input data format meets the required criteria, ensuring data accuracy and integrity.

For more details, check out the video below !!

Get a complete Roadmap To Learn Salesforce Admin And Development ๐Ÿ‘‡

Share Now

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *