You need to sign in to do that
Don't have an account?

For loop, not looping?
Ok, I find this weird, hoping for some help with the matter. Here are the basics:
Trigger on account, when the Account field Flags__c does not contain "Delinquent", and the Case owner is 'xxx' (Delinquent) it should replace the owner with a new owner. It works fine, each time I save the account, 1 case record is being updated. What I need, is for all the cases with the owner of delinquent to be updated at the same time, I thought the for loop would do this, but it is not. Here is my trigger:
trigger AccountDelinquentHoldRelesed on Account (After Update) {
Account AC = Trigger.New[0];
Set<Id> ACIds = new Set<Id>();
ACIds.add(AC.Id);
list<account> ACS = [select id, Flags__c from account where Id in :ACIds AND Flags__c EXCLUDES ('Delinquent') ];
list<case> CAS = [select id, OwnerID from case where Case.AccountID in :ACS AND Case.OwnerID = '00G60000002Ia7P'];
if(CAS.size() > 0 && ACS.size() > 0 ){
for (Case CAS2: CAS) {
{ CAS[0].OwnerID= '00G60000001Na1r';}
}
}
}
Trigger on account, when the Account field Flags__c does not contain "Delinquent", and the Case owner is 'xxx' (Delinquent) it should replace the owner with a new owner. It works fine, each time I save the account, 1 case record is being updated. What I need, is for all the cases with the owner of delinquent to be updated at the same time, I thought the for loop would do this, but it is not. Here is my trigger:
trigger AccountDelinquentHoldRelesed on Account (After Update) {
Account AC = Trigger.New[0];
Set<Id> ACIds = new Set<Id>();
ACIds.add(AC.Id);
list<account> ACS = [select id, Flags__c from account where Id in :ACIds AND Flags__c EXCLUDES ('Delinquent') ];
list<case> CAS = [select id, OwnerID from case where Case.AccountID in :ACS AND Case.OwnerID = '00G60000002Ia7P'];
if(CAS.size() > 0 && ACS.size() > 0 ){
for (Case CAS2: CAS) {
{ CAS[0].OwnerID= '00G60000001Na1r';}
}
}
}
trigger AccountDelinquentHoldRelesed on Account (After Update) {
Account AC = Trigger.New[0];
Set<Id> ACIds = new Set<Id>();
ACIds.add(AC.Id);
list<account> ACS = [select id, Flags__c from account where Id in :ACIds AND Flags__c EXCLUDES ('Delinquent') ];
list<case> CAS = [select id, OwnerID from case where Case.AccountID in :ACS AND Case.OwnerID = '00G60000002Ia7P'];
if(CAS.size() > 0 && ACS.size() > 0 ){
for (Case CAS2: CAS) {
{ CAS2.OwnerID= '00G60000001Na1r';}
}
update(CAS);
}
}