You need to sign in to do that
Don't have an account?
@GM
why Message is not displaying ??
trigger ToDisplayMessage on NEWOPTION__c (after insert) { List<NEWOPTION__c> ls=Trigger.new; for(NEWOPTION__c nw:ls) { if(nw.Opt__c == 'yes') { if(nw.Primary_interest__c != null && nw.Secondary_interest__c !=null) { if(ApexPages.currentPage() != null) { ApexPages.addMessage(new ApexPages.message(ApexPages.severity.info,'I like '+nw.Primary_interest__c+' specifically ‘+nw.Secondary_interest__c')); } } } } }
Hi..
try below code :
If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them.
Thnaks,
Cool Sfdc
The way to handle this is to use addError() in your trigger, and an exception handler in your controller.
Instead consider:
The bottom code chunk is in your controller.
You will want to check-out
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_System_SObject_instance_methods.htm for information on addError() and
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm for a list of all the special methods you can call on DML exceptions.
trigger testing2 on Account (after insert,after update) {
for (Account newOpp : Trigger.new) {
newOpp .addError('ok');
}
}
for more details visit the blog
http://salesforceglobe4u.blogspot.in/2013/12/how-to-display-error-message-from.html