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?

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

3 Answers 3

1

Try this

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

}
2
  • Adding some explanation as to why this works differently, would really increase the value of your answer Anu. Commented Jun 23, 2014 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. Commented Jun 23, 2014 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); }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .