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

Apex Trigger Help
Hello, I'm getting to following error message, any ideas? Thanks in advance!
System.ListException: List index out of bounds: 0: Class.ManageOpportunitiesBeforeUpdate.beforeUpdate: line 84, column 32
list<Opportunity> allopps = [select Id, AccountId, CreatedDate
from Opportunity
where Id in :accids
and CreatedDate in :createdDates
order by AccountId, CreatedDate];
map<Id, Integer> oppid2seqnummap = new map<Id, Integer>();
//reset placeholders: last Account, last Date, current counter
Id thisaccid = allopps[0].AccountId;
Date thisdate = allopps[0].CreatedDate.date();
Integer counter = 0;
Before getting the value from list check the size of the list.
Id thisaccid;
Date thisdate
list<Opportunity> allopps = [select Id, AccountId, CreatedDate
from Opportunity
where Id in :accids
and CreatedDate in :createdDates
order by AccountId, CreatedDate];
map<Id, Integer> oppid2seqnummap = new map<Id, Integer>();
//reset placeholders: last Account, last Date, current counter
if(allopps.size()>0){
thisaccid = allopps[0].AccountId;
thisdate = allopps[0].CreatedDate.date();
}
Integer counter = 0;