• mamatha devaraj
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
How can i fix this exception


     public static string billSpecSoInsert(Customer_Billing_Spec_Template__c billSpecins, List<Customer_Billing_Spec_SOMap__c> SoMapList, List<Cust_Billing_Spec_Extra_Parameter__c> billingExtParamList){
     
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert  billSpecins:'+billSpecins);
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList:'+SoMapList);
        
        
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList size:'+SoMapList.size());
        string status='success';
        try{
            
            insert billSpecins; 
            //NAD-4567(SF-8490): Order Extra Parameters Phase 2
            if(!billingExtParamList.isEmpty()){
                for(Cust_Billing_Spec_Extra_Parameter__c ep : billingExtParamList){
                    ep.Customer_Billing_Spec_Template__c = billSpecins.id;
                }
                upsert billingExtParamList;
            }
            
            if(!SoMapList.isEmpty()){
            
                for(Customer_Billing_Spec_SOMap__c billspecId : SoMapList){
                    
                    billspecId.Customer_Billing_Spec__c = billSpecins.id;
                }
            
                upsert SoMapList;                
            }
        }catch(DMLexception ex) {
            ECOB_LogUtility.createDMLExceptionLog(ex); 
            system.debug('exception1 '+ex.getCause());
            system.debug('exception2'+ex.getMessage());
            status = ex.getMessage();
        }
      return status;
    }
    
    Thanks in advance
I got below exception msg
USER_DEBUG [283]|DEBUG|exception2Insert failed. First exception on row 0 with id a7o3K000000DwPWQA0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]




public static string billSpecSoInsert(Customer_Billing_Spec_Template__c billSpecins, List<Customer_Billing_Spec_SOMap__c> SoMapList, List<Cust_Billing_Spec_Extra_Parameter__c> billingExtParamList){
     
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert  billSpecins:'+billSpecins);
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList:'+SoMapList);
        
        
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList size:'+SoMapList.size());
        string status='Success';
        try{
            insert billSpecins;            
            
            //NAD-4567(SF-8490): Order Extra Parameters Phase 2
            if(!billingExtParamList.isEmpty()){
                for(Cust_Billing_Spec_Extra_Parameter__c ep : billingExtParamList){
                    ep.Customer_Billing_Spec_Template__c = billSpecins.id;
                }
                insert billingExtParamList;
            }
            
            if(!SoMapList.isEmpty()){
            
                for(Customer_Billing_Spec_SOMap__c billspecId : SoMapList){
                    
                    billspecId.Customer_Billing_Spec__c = billSpecins.id;
                }
            
                insert SoMapList;                
            }
        }catch(DMLexception ex) {
            ECOB_LogUtility.createDMLExceptionLog(ex); 
            system.debug('exception1 '+ex.getCause());
            system.debug('exception2'+ex.getMessage());
            status = ex.getMessage();
        }
      return status;
    }
    
    
I wrote this code but it is not working, help me for this

Thanks in advance

trigger FindDuplicatecases on Case (after insert) {
    system.debug('tset');
    
    String policyVariable;
    String typevalue;
    Datetime createdDateValue;
    List<Case> caseList = New List<Case>();
    List<Case> cadup = New List<Case>();
    Set<Case> caseSet = New Set<Case>();
    
    for(Case c:trigger.new){
        if(c.policy__c != null && c.Type == 'QRC'){
            policyVariable = c.policy__c;
            typevalue = c.Type;
            createdDateValue = c.CreatedDate;
        }
    }
    system.debug('policyVariable>>> '+policyVariable);
    system.debug('typevalue>>> '+typevalue);
    
    if(policyVariable != null && typevalue == 'QRC'){
        system.debug('in>>>> ');
        cadup =[select id, policy__c, Type, ParentId from case where policy__c =: policyVariable  AND Type = 'QRC' ];
    }
    system.debug('cadup>>>> '+cadup);
    
    if(cadup.size() > 0){
        for(case cs : trigger.new){
            for(case cse : cadup){
     system.debug('oldcaseid'+cse);
                Case ce = New Case();
                ce.Id = cs.Id;
                ce.ParentId = cse.Id;
                caseSet.add(ce);
            }
        }
    }
    system.debug('caseSet>>>> '+caseSet);
    
    for(Case csSet : caseSet){
        caseList.add(csSet);
    }
    
  
        Update caseList;
    
}
I got below exception msg
USER_DEBUG [283]|DEBUG|exception2Insert failed. First exception on row 0 with id a7o3K000000DwPWQA0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]




public static string billSpecSoInsert(Customer_Billing_Spec_Template__c billSpecins, List<Customer_Billing_Spec_SOMap__c> SoMapList, List<Cust_Billing_Spec_Extra_Parameter__c> billingExtParamList){
     
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert  billSpecins:'+billSpecins);
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList:'+SoMapList);
        
        
        System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList size:'+SoMapList.size());
        string status='Success';
        try{
            insert billSpecins;            
            
            //NAD-4567(SF-8490): Order Extra Parameters Phase 2
            if(!billingExtParamList.isEmpty()){
                for(Cust_Billing_Spec_Extra_Parameter__c ep : billingExtParamList){
                    ep.Customer_Billing_Spec_Template__c = billSpecins.id;
                }
                insert billingExtParamList;
            }
            
            if(!SoMapList.isEmpty()){
            
                for(Customer_Billing_Spec_SOMap__c billspecId : SoMapList){
                    
                    billspecId.Customer_Billing_Spec__c = billSpecins.id;
                }
            
                insert SoMapList;                
            }
        }catch(DMLexception ex) {
            ECOB_LogUtility.createDMLExceptionLog(ex); 
            system.debug('exception1 '+ex.getCause());
            system.debug('exception2'+ex.getMessage());
            status = ex.getMessage();
        }
      return status;
    }
    
    
I wrote this code but it is not working, help me for this

Thanks in advance

trigger FindDuplicatecases on Case (after insert) {
    system.debug('tset');
    
    String policyVariable;
    String typevalue;
    Datetime createdDateValue;
    List<Case> caseList = New List<Case>();
    List<Case> cadup = New List<Case>();
    Set<Case> caseSet = New Set<Case>();
    
    for(Case c:trigger.new){
        if(c.policy__c != null && c.Type == 'QRC'){
            policyVariable = c.policy__c;
            typevalue = c.Type;
            createdDateValue = c.CreatedDate;
        }
    }
    system.debug('policyVariable>>> '+policyVariable);
    system.debug('typevalue>>> '+typevalue);
    
    if(policyVariable != null && typevalue == 'QRC'){
        system.debug('in>>>> ');
        cadup =[select id, policy__c, Type, ParentId from case where policy__c =: policyVariable  AND Type = 'QRC' ];
    }
    system.debug('cadup>>>> '+cadup);
    
    if(cadup.size() > 0){
        for(case cs : trigger.new){
            for(case cse : cadup){
     system.debug('oldcaseid'+cse);
                Case ce = New Case();
                ce.Id = cs.Id;
                ce.ParentId = cse.Id;
                caseSet.add(ce);
            }
        }
    }
    system.debug('caseSet>>>> '+caseSet);
    
    for(Case csSet : caseSet){
        caseList.add(csSet);
    }
    
  
        Update caseList;
    
}