Salesforce 如果帐户中的地址发生更改,则应在所有相关联系人中复制该地址';地址

Salesforce 如果帐户中的地址发生更改,则应在所有相关联系人中复制该地址';地址,salesforce,Salesforce,如何在salesforce和bulkifyit中使用触发器 有很多方法可以做到这一点,这里有一种方法可以从您的帐户触发器调用: public static void afterUpdate(List<Account> newList, List<Account> oldList){ Set<Id> accountIds = new Set<Id>(); for ( Integer i=0;i<newList.size();i++ ){

如何在salesforcebulkifyit中使用触发器

有很多方法可以做到这一点,这里有一种方法可以从您的帐户触发器调用:

public static void afterUpdate(List<Account> newList, List<Account> oldList){
  Set<Id> accountIds = new Set<Id>();
  for ( Integer i=0;i<newList.size();i++ ){
    if ( newList[i].BillingStreet != oldList[i].BillingStreet ){
      accountIds.add(newList[i].Id);
    }
  }
  List<Contact> contactsToUpdate = new List<Contact>();
  for ( Contact c : [
    SELECT Id, MailingStreet, Account.BillingStreet
    FROM Contact
    WHERE AccountId IN :accountIds
  ]){
    if ( c.MailingStreet != c.Account.BillingStreet ){
      c.MailingStreet = c.Account.BillingStreet;
      contactsToUpdate.add(c);
    }
  }
  if ( contactsToUpdate.size() > 0 ){
    update contactsToUpdate;
  }
}
publicstaticvoidafterupdate(List newList,List oldList){
Set accountIds=new Set();
for(整数i=0;i 0){
更新联系人更新;
}
}

您是否已尝试以某种方式实现它?对于Apex触发器或SF工作流,这看起来像是常见的情况