apex addError - remove default error message

这一生的挚爱 提交于 2019-12-13 03:54:11

问题


I have added addError to my record like in the following. v.addError('My Error message');

But I get the error message like in the following.

I don't want the default part "Error: Invalid Data. Review all error messages to correct your data".

I tried adding to some field instead of adding it to the whole record. But in this case, it implies that the error is specific to what the user has entered in that field. But this is not what I want. My error is record specific.

In a nutshell, based on some condition, I want to stop a record being inserted. This is actually to be added to before insert of my trigger.

Please help.


回答1:


Try this Code for field level error message:

trigger AccountTrigger on Account (before insert) {
    for(Account accIns  :trigger.new){
        if(accIns.Rating == 'Hot'){
            accIns.Rating.addError('My Error message');
        }
    }
}


来源:https://stackoverflow.com/questions/55635709/apex-adderror-remove-default-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!