You need to sign in to do that
Don't have an account?
SFDC Apex Dev
Please help me to bulkify the below trigger
trigger LinkEnCusToAccP on Acc_P__c (before insert, before update) {
// Data load bypass
if(IsUtil.adminByPass()) return;
Private Integer iCount = 0;
for (Acc_P__c a : Trigger.new) {
if(Trigger.isUpdate) {
if(a.Account__c != Trigger.old[iCount].Account__c) {
a.Ent_Cus__c = [select Ent_Cus__c from Account where Id = :a.Account__c limit 1].Ent_Cus__c;
}
iCount++;
} else {
if(a.Account__c != null) {
a.Ent_Cus__c = [select Ent_Cus__c from Account where Id = :a.Account__c limit 1].Ent_Cus__c;
}
}
}
}
// Data load bypass
if(IsUtil.adminByPass()) return;
Private Integer iCount = 0;
for (Acc_P__c a : Trigger.new) {
if(Trigger.isUpdate) {
if(a.Account__c != Trigger.old[iCount].Account__c) {
a.Ent_Cus__c = [select Ent_Cus__c from Account where Id = :a.Account__c limit 1].Ent_Cus__c;
}
iCount++;
} else {
if(a.Account__c != null) {
a.Ent_Cus__c = [select Ent_Cus__c from Account where Id = :a.Account__c limit 1].Ent_Cus__c;
}
}
}
}
Abdul Khatri
try this