2

I have a trigger in which error message is getting displayed in a standrad page using adderror method.Which gives an error

Error: Invalid Data. Review all error messages below to correct your data.

I want to disable this message and only need to display my customize message.

Is it possible?

  • Are you still experiencing this error? – Davin Casey Aug 22 '14 at 14:06
  • @DavinC yes!I kept as it is and added my error message below it. – SalesforceAspiration Aug 22 '14 at 14:37
  • Add your changes to your post and hopefully we can get it resolved for you. – Davin Casey Aug 22 '14 at 14:39
1

Try this

for(Session__c sNew : trigger.new)
{
   sNew.addError('Overlap Session');

}
  • Adding some explanation as to why this works differently, would really increase the value of your answer Anu. – Samuel De Rycke Jun 23 '14 at 13:14
  • Thanks Anu.It will give -Error: Invalid Data. Review all error messages below to correct your data.Overlap Session.But this is not the answer to my question. – SalesforceAspiration Jun 23 '14 at 15:43
1

Use a try/catch block around your DML:

try
{
  upsert someObj;
} catch (Exception e)
{
  ApexPages.addMessage(new ApexPages.Message('some custom message', WARNING);
}

The Syntax isn't 100% correct, but I believe it's somewhat close. If you are already posting messages to your page you should already know what to do.

0

This is a very simple solution to my question :)

if ( some condition) { String errStr ='Error message'; ac.addError(errStr); }

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.