0

i often found this error online but couldn`t solve the problem myself. The Line:

"accId = string.valueOf([Select accountname__c From Abo__c where Id =:aboId ]);"

causing the problem. Does anybody see my mistake. The rest of my code looks like this:

trigger UpdateKuendigungsrisikoAccount on Reklamation__c (after insert) {

//Variablen 
Map<Id,Integer> listOfAccountIds = new Map<Id,Integer>();
Map<Id, Integer> listOfAboIds = new Map<Id, Integer>();
Schema.Account newKuendigungsrisiko;
String accId;
Integer anzahlReklamationen = 0;

//Eine liste sämtlicher aktiver Abo.Ids mit entsprechender Anzahl an Reklamationen
for(Reklamation__c rec : trigger.new){
    anzahlReklamationen = [Select COUNT() From Reklamation__c where Id =: rec.Id];
    listOfAboIds.put(rec.abonr__c, anzahlReklamationen);
}

//Eine Liste sämtlicher aktiver Account.Ids mit entsprechender Anzahl an Reklamationen
for(Id aboId: listOfAboIds.keySet()){
    accId = string.valueOf([Select accountname__c From Abo__c where Id =:aboId ]);
    listOfAccountIds.put(accId,listOfAboIds.get(accId));
}
1
  • Change your Map into type of Map<String,Integer> and final loop as for(String aboId: listOfAboIds.keySet()){}
    – highfive
    Commented Apr 19, 2016 at 8:32

1 Answer 1

0
trigger UpdateKuendigungsrisikoAccount on Reklamation__c (after insert) {

//Variablen 
Map<Id,Integer> listOfAccountIds = new Map<Id,Integer>();
Map<Id, Integer> listOfAboIds = new Map<Id, Integer>();
List<Id> myaccids = new List<Id>();

Schema.Account newKuendigungsrisiko;
String accId;
Integer anzahlReklamationen = 0;
integer counter =0;

//Eine liste sämtlicher aktiver Abo.Ids mit entsprechender Anzahl an Reklamationen
for(Reklamation__c rec : trigger.new){
    anzahlReklamationen = [Select COUNT() From Reklamation__c where Id =: rec.Id];
    listOfAboIds.put(rec.abonr__c, anzahlReklamationen);
}
myccids  =[Select accountname__c From Abo__c where Id in : listOfAboIds.keySet()];

//Eine Liste sämtlicher aktiver Account.Ids mit entsprechender Anzahl an Reklamationen
for(Id aboId: listOfAboIds.keySet()){
//    accId = string.valueOf([Select accountname__c From Abo__c where Id =:aboId ]);
    listOfAccountIds.put(myaccids[counter],counter);
  counter ++;

}
1
  • unable to format ,apologies
    – ram r
    Commented Apr 19, 2016 at 8:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .