+ Start a Discussion
SandrineSandrine 

Display error message to user on screen ifexception is raised in trigger

Hello,

If i have a triggers on account,
If the trigger goes in exception loop, i want to display a error mesage "not valied" on the page and halt further proceeding of the page, i mean not let the user to save the page..

how can this be done
Best Answer chosen by Sandrine
swati_sehrawatswati_sehrawat
try{
	//Do code
}catch(Exception e){
	trigger.new[0].addError('Error Message.');
}


 

This can help

All Answers

Aniket Malvankar 10Aniket Malvankar 10
Hello Sandrine,

You can .addError(''XYZ);
swati_sehrawatswati_sehrawat
try{
	//Do code
}catch(Exception e){
	trigger.new[0].addError('Error Message.');
}


 

This can help

This was selected as the best answer