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? Aug 22, 2014 at 14:06
  • @DavinC yes!I kept as it is and added my error message below it. Aug 22, 2014 at 14:37
  • Add your changes to your post and hopefully we can get it resolved for you. 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. 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. 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 .