【问题标题】:Salesforce email triggerSalesforce 电子邮件触发器
【发布时间】:2020-03-30 13:28:49
【问题描述】:

你好请帮我朋友写代码,他的任务是

如果电子邮件没有“com.Net”,则不应插入或更新联系人,电子邮件是联系人的自定义归档。我希望你通过触发来做到这一点,这个触发器应该只在插入和更改电子邮件时触发

code he write

他写的代码:

trigger InsertedUpdated on Contact (before insert,before update){
  for(contact con:trigger.new)

      if( con.Email=='xyz@gmail.com'){
            // con.Last='.com /.net';
     }

       for( contact con:trigger.new ){
       if(con.Email!=trigger.Oldmap.get(con.Id).Email || con.Email!=trigger.Oldmap.get(con.Id).Email){
           if( con.Email=='xyz@gmail.com' ){
            con.adderror('Email does not correct ');
           }

       x

       }
       }

}

【问题讨论】:

  • 请将代码插入文本,格式化为代码,而不是图片。
  • 完成请检查

标签: salesforce


【解决方案1】:

是否需要使用触发器?验证规则似乎更适合此用例,并且在违反时会提供更友好的错误。
您可以在验证规则 here
中找到有关使用正则表达式的信息 如果绝对需要使用触发器,this page 有一个如何在 apex 中编写正则表达式的示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2022-11-11
    • 2022-11-20
    • 1970-01-01
    相关资源
    最近更新 更多