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
communitycommunity 

Break tag in Add Error Method for Trigger?

Hi All,

 

I am using addError method in a trigger to show some error messages.  I need to show the error message in two different lines, like below

 

***DO NOT ISSUE THIS ORDER***

***The order is currently with the DEV team***

 

I am unable to add the break between the lines. I tried the below:

 

AMet[0].addError('***DO NOT ISSUE THIS ORDER***'+BR()+'***The order is currently with the DEV team***');

 

But it says, there is no BR() method.

 

Help!!!

 

Thanks,

community

Best Answer chosen by Admin (Salesforce Developers) 
communitycommunity

Finally, this worked!

 

String sBreak = '</br>';

 

AMet[0].addError('***DO NOT ISSUE THIS ORDER***'+sBreak+'***The order is currently with the DEV team***');

All Answers

communitycommunity

Finally, this worked!

 

String sBreak = '</br>';

 

AMet[0].addError('***DO NOT ISSUE THIS ORDER***'+sBreak+'***The order is currently with the DEV team***');

This was selected as the best answer
Prashant DhanagarPrashant Dhanagar
Sorry this is not working.Ihave tried this but got failure.
RangnathRangnath
The best way to implement the line break is to go for html message in addError.
Ex : tt.addError('<span><b>Enter time in format</b></br><b>HH:MM:SS</b></span>',false);
Kondal Rao learnerKondal Rao learner
Hi Rangnath,

thanks for the post its working perfectly , it will be very usefull to everyone, who ever wants to use break in trigger or apex class
gowtham murugesangowtham murugesan
Hi Rangnath,
tt.addError('<span><b>Enter time in format</b></br><b>HH:MM:SS</b></span>',false);

the above code is working fine in classic but in lightining its not working,kindly provide me the solution 
Thanks