apex addError

编程入门 行业动态 更新时间:2024-10-27 08:38:20
本文介绍了apex addError - 删除默认错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我已将 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 17:27:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/943771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:apex   addError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!