function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naofumi KunNaofumi Kun 

Creating a Catch for the error: External entry point

There is validation that I made but not using a Validation Rule.

Entries with the same Product Name within its Parent Object will be prevented. So for example, a user cannot input 2 ProductA within the Company.

I created this by creating a UNIQUE text field, and have a WF populate this using the LookupID+ProductName.

I already have an existing catch for custom validations, any ideas on how would I insert a catch for this?
public void Product(){
   try {
    upsert revenueSchedules;
    catch(System.DmlException e) {
   String S1 = e.getMessage();
        S1 = S1.substringBetween('FIELD_CUSTOM_VALIDATION_EXCEPTION, ' , ': [');
       ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,S1 ));