apex addError-删除默认错误消息 [英] apex addError - remove default error message

查看:84
本文介绍了apex addError-删除默认错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将addError添加到我的记录中,如下所示. v.addError('我的错误消息');

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.

请帮助.

推荐答案

尝试使用此代码获取字段级错误消息:

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');
        }
    }
}

这篇关于apex addError-删除默认错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆