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

查看:20
本文介绍了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:

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天全站免登陆