Triggers 限制异常:SOQL查询太多
当我尝试为这个apex触发器使用数据加载器时,我收到一个异常。它说一次只能更新100条记录。下面是解释Account对象上的触发器的代码。非常感谢所有评论Triggers 限制异常:SOQL查询太多,triggers,salesforce,limit,apex,Triggers,Salesforce,Limit,Apex,当我尝试为这个apex触发器使用数据加载器时,我收到一个异常。它说一次只能更新100条记录。下面是解释Account对象上的触发器的代码。非常感谢所有评论 trigger MaintainPrimaryOverriding on Account (before insert, before update) { if (TriggerUpdateController.getPrimaryBranchOverriding()){ TriggerAffiliationCo
trigger MaintainPrimaryOverriding on Account (before insert, before update) {
if (TriggerUpdateController.getPrimaryBranchOverriding()){
TriggerAffiliationControl.setLock();
for(Account s : Trigger.new)
{
if (Trigger.isUpdate){
Id ownerId = Trigger.oldMap.get(s.Id).OwnerId;
if (s.OwnerId != ownerId){
//Use Branch Associated with owner ID
TriggerUpdateController.UpdatePrimaryBranchOfficeForAccountOwnerChange(s);
TriggerUpdateController.UpdateAffiliation(s);
}
}
else if(Trigger.isInsert){
TriggerUpdateController.UpdatePrimaryBranchOfficeForAccountOwnerChange(s);
}
}
TriggerAffiliationControl.setUnLock();
}
}
谢谢 此错误太多SOQL查询是因为您达到了调控器限制。查看看起来您在代码中为每个更新/插入记录调用以下方法 “TriggerUpdateControl.UpdatePrimaryBranchOfficeForAccountOwnerChange” “TriggerUpdateControl.UpdateAffiliation” 看起来您正在上述语句中发出SOQL语句,这导致了管理限制错误 这里需要做两个修改。 1.捕获列表中已更新或插入的帐户列表,并将它们传递给上述两种方法。 2.使用上述两种方法接受步骤1中创建的帐户列表并进行处理。 3.如果要从其他对象获取详细信息,请在SOQL中获取这些详细信息 如果您可以发布“TriggerUpdateControl”的代码,我将更好地向您推荐正确的代码 问候,, Pundarekam Kudikala