I have the following apex code where I do a soql. In my developer sandbox my testclass gives me 100% coverage. When I deploy this to production I get the error:
System.ListException: List index out of bounds: 0
My error is on the line with: AFAS_ID__c= afas1[0].id
if(acc[x].BUMA_Achtergrondmuziek__c !='N.v.t.'){
List <AFAS_Artikel__c> afas1= [SELECT id, AFAS_Code__c FROM AFAS_Artikel__c WHERE AFAS_Code__c = : acc[x].BUMA_Achtergrondmuziek__c LIMIT 1];
Factuurregel__c fa =new Factuurregel__c(Organisatie__c=acc[x].id, Debiteur__c = acc[x].Debiteurennummer__c ,
Aantal__c = 1
, AFAS_ID__c= afas1[0].id
, Factuurdatum__c= date.today(),Referentie__c = ''+ System.Today().year());
}