2

Apex trigger quotepotential caused an unexpected exception, contact your administrator: quotepotential: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.quotepotential: line 10, column 1

thsi is the error i am getting how to clear this error

trigger quotepotential on Quote_Line_Item__c (after insert, after update) {
    Set<Id> quoteIds = new Set<Id>();
    List<Quote__c> quotes = new List<Quote__c>();
    for(Quote_Line_Item__c record: Trigger.new) {
        quoteIds.add(record.Quote1__c);
    }
    for(AggregateResult ar:[SELECT Quote1__c id, SUM(Max_Batch__c)sumMax FROM Quote_Line_Item__c WHERE Quote1__c=:quoteIds GROUP BY Quote1__c]) {
       quotes.add(new Quote__c(Id=(Id)ar.get('Id'), Potential__c=(Decimal)ar.get('sumMax')));
}
  update quotes;
}
1
  • hi any idea to get rid of error
    – Teja
    Nov 14 '13 at 6:49
4

are you sure that quote1__c is not null ?? can you please try filtering out nulls ?

   for(Quote_Line_Item__c record: Trigger.new) {
        if (record.Quote1__c != null)
        {
           quoteIds.add(record.Quote1__c);
        }
   }
3
  • Could be the reason .You may be right .+1 Nov 14 '13 at 7:21
  • superb it worked
    – Teja
    Nov 14 '13 at 7:23
  • @user4045 Please mark it ticked and upvote.Thats how this community works Nov 14 '13 at 7:27
1
trigger quotepotential on Quote_Line_Item__c (after insert, after update) {
Set<Id> quoteIds = new Set<Id>();
Map<Id,decimal> mapIdbySum=new Map<Id,decimal>();
List<Quote__c> quotes = new List<Quote__c>();
for(Quote_Line_Item__c record: Trigger.new) {
    if(record.Quote1__c!=null){
      quoteIds.add(record.Quote1__c);
    }
}
 for(AggregateResult ar:[SELECT Quote1__c id, SUM(Max_Batch__c)sumMax FROM   Quote_Line_Item__c WHERE Quote1__c=:quoteIds GROUP BY Quote1__c]) {
   quotes.add(new Quote__c(Id=(Id)ar.get('Id'), Potential__c=(Decimal)ar.get('sumMax')));
 }
   update quotes;
  }

i have added a null check at the beginning as parent Id can go null if its lookup relationship .

3
  • no mohit it is taking ,already i tried changing that one
    – Teja
    Nov 14 '13 at 7:02
  • Any other idea .
    – Teja
    Nov 14 '13 at 7:03
  • Modified code .Please see if that helps Nov 14 '13 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.