Blog

02/10/2023

Winter 24- custom error message using Record Triggered Flow

Quite a buzz going around in the Salesforce ecosystem about the Winter-24 release features especially related to lightning flow. So let’s discuss one of the features i.e. Display custom error messages using Record Triggered flow.

Use Case :-

Universal Containers has implemented CPQ & they are heavily using Quote Line Groups so that the Sales Rep can categorise the quote lines based upon the family of products like software, hardware or support products. Dates play a crucial role while doing the quotation in CPQ, so the business came up with a requirement, i.e. Quote Line Group Start Date & End Date should lie in between the Quote’s Start Date & End Date.

Implementation

One can choose either Apex Trigger or Record Triggered Flow to implement the solution, but one of the developers decided to use Record Triggered Flow using the Custom Error Element introduced by Salesforce in the Winter-24 release.

  1. Setup -> Quick Find -> Flows

ex-p_PLslAAbyTJj2Nlh0Y7kmd7wFBSB7w6Gi50ZDTjd9js6yh0oFvXM061CPkoDYrCz-S0kr4R49sNd7tpNgsuc6Io9od6_jzwHFJhP-Dv5YfcxTlB6XX6oepgUJTnBHAB4QsPyqniQt9IItCrOur0.png

Navigate To Flows

2. Click on New Flow -> Choose Record Triggered Flow -> Create

0wR5TxJmwnT1fclvVWE_kJtvRWFwQFsagUn1MHokKNgubAKWGwXesH-Pwg6iWtRRdOf9metJ6HtgMDNL0aQED2QIbBZWAriD0XO5d7pHk-7yfxkpuTz6E8w8eRyWS5HLYdFQXE0dmCZf_MqfmklARa4.png

New Flow

V7UvYL7H1ARnUjg2eGJDjAxRuSk9BAi2E4ZHcySEOpRlbk4vWJovMKgLeNmhwaVERu3MaZbPEUI4IQ_DyKDIjEVW5LUpw7JvCo8E1M-RgXM-y5fj5bJcNBIZXx6MCgZ70HgyGcfY3mox4z0mLfjEh8g.png

Record-Triggered Flow

Note: Custom Error Element is only available in Record Triggered Flows.

3. Configure the Start Element as shown below:-

JgbxHaOeActpnDNcGFSmRzkRNnOiQMPt_RuldfXsKh4N9Plxvi5_RmWYftql0nkcRqtQ3Ij7SEp6VyEObYBpwRZYh3ywXAsoh9BebygUdXnh-RwrhxZhge7y00jQrAtK3_k3OQUADDOsE8g4CJI5VGM.png

4. Use the Decision Box Element to compare the Quote line Group dates with Quote Dates.

5OSx8CYrpGH2X_UN-sm-M3mH6_LMnbilB_bryGcBBaFqORbNZcAunrJiSx1HHN1t5RDK_fg4_cMM_JrGV98AfOu1guaEN5dHDuMkqh801YhlwY3stjiVBOG3zRQvBcMQViYOzSRetUSW63uPQLNDHG8.png

5. Select Custom Error Element & Configure to display the error message as shown below:-

zaYqLFeQOJkpIxVlt4YUXT5ZOjpdVE3IhsX78Rmes1vVnPbyLrgORwqVjmgfPEf1IYAiHmPRMbACqUYAVFNmKLU-fIUwkzD1pLCQrCe7kBmK8xgXcpoelE5-fVbVQWeFQCBJTBFQsoYn-588Ag-0fV4.png

Choose Custom Error

AcMxeZl0FMFvDvzfc-djSqPlWv8X1go2AMaz5X4NaaTh3PUhs8e7XdvCDYQEGxOa3nzgTl9fqG2jxbD4sXwRlT-y9JgKuBXaMlZaa8MlaDiBbm-d2Y55qzcVtX8YAJg0V9g0sXa9Rn04WQWTxrKSu9s.png

Variable to Store the Error Message

SZLwI8svcrsWYp2BtsHegS4KMF1K-Dy5bdGt0LRQNKJKj6bCau4ymCOaoBJtZ9pi5Uwrx1dxuM2jdJPF4WQ5FGShaGgjyVLm0grrn_kAvdsx4vk8yR1kTvU_Xi-j6if_V8o5LEjYFLGruAXtgXOC3i8.png

Configure Custom Error Element

Points To Remember :

  • Error Messages can be visible either on a particular field or on the record page.
  • You can add multiple error messages when it comes to field-level visibility.

6. Save -> Activate & Test out the whole functionality.

Cdlt020nHRftGpYynXKrgeWKc2JZmrzziI2bt-CKBQmZrWfSe7sg1ljIaHZERB1r7RaEg1rh8z4EjjOXeS_LnEEPxc4Frghrce-KLxO0sW05h_emaQ3Ix9Z4CSaDMeYepxWH0c_5T-OR5reZ7D1sY60.png

Save Configuration

ktUXaozTel8xUZc1NtGdj7OkoIp8rK3qh3ya-NHAcI4XcqTwdCazEcQhRVFyfLCg9jkv7d9OUwIGLCZi735lSmmv-PlwGbSjb3Qmp0fD4n3gq3eOwgeSnNf2hAdQGCh3nslieI7iPPL-tmmdAN6ZtYY.png

Activate Flow

4YKg_JdtffLSRwv9yyp8pX3Dl9pjU3ejoUY2P5Neey19Wm01uUxZ1k3tmI9MxhgV35jZ1fBoLJv_Pko8snVm2e44ZBqV433Vd2g3zBqK3Ig1IbMDdz72Kujw88PFQu8S5T3CuExD9d7k33MBo2xNWfI.png

Display Error Message

Notes:-

  • The above image clearly shows the quote line group start date is 24th August, which is before the quote start date. That’s the reason the system is not allowing us to save the configuration.

Limitations:-

  • Do not use any DML or Assignment Element after the Custom Error Element. If you do so, then you won’t be able to see the validation message since flow bypasses the custom error element and executes the DML or Assignment, whichever is configured.

Demo: 

Dixit Khurana

Senior Salesforce Developer

Read next

04/10/2023

A gift of a complaint

Contact us

Contact us