• #15032
    Salesforce | PRANAV PRANAV #1
    Forcetalks

    How to add error message in a Salesforce Apex Trigger?

    Hi All,

    How to add error message in apex trigger ?

    Thanks

    Tagged: , , ,

    #15039
    Salesforce | Abhinav Abhinav #215
    Forcetalks

    Hi Pranav,

    Test__c trigObj = trigger.newMap.get(Test.id);
    if(trigObj != null){
    trigObj.addError(‘Cloned record should not have the same period as that of Parent record’);
    }

    #21038
    Salesforce | shariq shariq #187
    Forcetalks

    Hi Pranav,

    Yes you can add error messages in triggers by using Salesforce trigger addError method.
    For Example – Sobject.addError(‘Error Messages’);

    • This reply was modified 9 months, 1 week ago by Salesforce | shariq shariq.
    #27405
     Ratnakar #10
    Forcetalks

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,’Enter Your error message here’));

    #27407
    Salesforce | PRANAV PRANAV #1
    Forcetalks

    Hi Ratnakar,

    Whatever you are saying is not correct.

    The solution given by Abhinav is correct and helpful. And the issue resolves previously.

    I appreciate your response if it works for the same but the reply provided by you works for VF page only.

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?