• ankit bansal
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I upserted 150 records wiith salesforce data loader. The batch size was set as 200.A single record in that 150 records failed to upload but the error was shown for all the 150 and none of the record was upserted,but in a seperate incident the data loader upserted 149 records and showed error for only that one record. What is this behaviour of data loader and how can it be changed ?
I upserted 150 records wiith salesforce data loader. The batch size was set as 200.A single record in that 150 records failed to upload but the error was shown for all the 150 and none of the record was upserted,but in a seperate incident the data loader upserted 149 records and showed error for only that one record. What is this behaviour of data loader and how can it be changed ?
public with sharing class opptycon
{
public static void updateContracts(Map<Id, Opportunity> opps){

        List<Contract> contractsToUpdate = new List<Contract>();

        List<Contract> contracts = getContractsByOppIds(opps.keyset());

        String manualOrderOutcome = CustomMetadataServices.getContractSettingsText('Manual_Ordering_Processing');

        for(Opportunity opp : opps.values()){

            List<ContractSortWrapper> contractListForOpportunity = ContractSortWrapper.getAllByOpportunityId(contracts, opp.Id);
            contractListForOpportunity.sort();

            if(!contractListForOpportunity.isEmpty()) {

                if(contractListForOpportunity[0].con.Total_ASOP_Submissions__c >= 1 && opp.Current_Process_State__c == 'Order' && (opp.TBC_Initial_Response__c == NULL || opp.TBC_Initial_Response__c == 'ERROR' ) && String.isBlank(opp.Order_Outcome__c)){


                    contractListForOpportunity[0].con.Order_Submission_Outcome__c = CustomMetadataServices.getContractSettingsText('Work_Support_Team');
                    contractListForOpportunity[0].con.Online_Customer_Experience__c = TRUE;
                    contractListForOpportunity[0].con.Order_Outcome__c = CustomMetadataServices.getContractSettingsText('WSS');
                    contractListForOpportunity[0].con.Order_Kickback_Reason__c = CustomMetadataServices.getKickbackReasonValue('System Error');
                    contractListForOpportunity[0].con.Customer_Email_Comments__c = opp.Customer_Email_Comments__c;
                    
                    opp.Order_Outcome__c = CustomMetadataServices.getContractSettingsText('WSS');
                    opp.Online_Customer_Experience__c = TRUE;

                    contractsToUpdate.add(contractListForOpportunity[0].con);
                }
                else{
                    contractListForOpportunity[0].con.Customer_Email_Comments__c = opp.Customer_Email_Comments__c;
                    contractsToUpdate.add(contractListForOpportunity[0].con);                    
                }
                    
            }

        }

        try{

            update contractsToUpdate;
            system.debug('CONTRACTS UPDATED ' + contractsToUpdate);
        }
        catch(DmlException ex){

            System.debug('ERROR WHILE UPDATING CONTRACTS: ' + ex.getMessage());
        }
    }

    public static List<Contract> getContractsByOppIds(Set<Id> oppIds){

        return [SELECT Order_Submission_Outcome__c, Online_Customer_Experience__c, Order_Outcome__c, Opportunity__c, Order_Kickback_Description__c, Send_Order_Form__c, Total_ASOP_Submissions__c, CreatedDate FROM Contract WHERE Opportunity__c IN :oppIds];
    }

}