0

enter image description here

Controller: Database.SaveResult[] sr = opportunityhandler.createOpportunity(oppObj); isErrorOcurred = checkErrorsInResult(sr); System.debug('isErrorOcurred>>>'+isErrorOcurred); if( isErrorOcurred ){ return null;

        }

    }
    //Catching if any exceptions occurs
    catch(Exception e){
        //PROJ-1831055_BREQ-034 changes
        //ApexPages.addmessages(e);

        System.debug('isErrorOcurred>>>'+isErrorOcurred);
        // Commenting the  below line of code as a part of SR-00248389 Fix as User is not getting any error message displayed in the UI even though the Opportunity validation rule is getting fired - Opp_Currency_Msg_For_Child_Single
        //ApexPages.Message myMsg =  new ApexPages.Message(ApexPages.Severity.ERROR,'Error:' + e.getMessage());
        //Added the below line of code as a part of SR-00333988 fix : Pallavi Shewale
          if (e instanceof DMLException) {
                //throw new My1Exception('First exception'); 
                //ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Review error in this page.'));
                System.debug('**********Line215***********');
                ApexPages.addMessages(e);   

            }
           else{         
        // Added the below line of code as a part of SR-00248389 fix : Ponna Gopal
                 System.debug('**********Line220***********');
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error:' + e.getMessage()));

           }
    }       

Visualforce page:

  <!--PROJ-1941831_BREQ-048 || Duplicate button removal-->
  <apex:pageBlockButtons location="{! IF($User.UIThemeDisplayed == 'Theme3', '', 'top')}" >
      <apex:commandButton value="{!$Label.Save}" action="{!save}" onClick="disableOnSubmit(this);"/>
      <apex:commandButton value="{!$Label.Save_And_New}" action="{!saveAndNew}" onClick="disableOnSubmit(this);"/>
      <apex:commandButton value="{!$Label.Cancel}" action="{!cancel}" immediate="true" onClick="disableOnSubmit(this);"/>
  </apex:pageBlockButtons>
  .......

I want to override Error message at the top of the page with custom error message "Review all errors". How can I achieve this?

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.