function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion 

How to execute remaining records after entering into Catch Block ?

While parsing an XML file with 10 records, it fails at 6th record. It then enters in catch block  and prints an error statement.

But i want to process the remaining 3 records also.


Is there any way to process the remaining records also, plz help.




Can you tell us a bit more about how you are parsing the XML?  It rather depends if this is a recoverable error or not.

Thanks for your reply but I am able to parse the xml file, thats not the issue.


Here is the sample code:


                upsert AccountList;
        catch(exception e)
            ret = 'There seems to have been an exception while upserting records;
            ret += e;
            return ret;



 AccountList is an array and it is auto-populated, but half way through, it fails at some point and catch block gets executed. Now i want to process rest records also present in AccountList.


Plz help.


Use Database upsert opt_allOrNone option


Database Method Syntax

UpsertResult Database.Upsert(sObject recordToUpsert, Schema.SObjectField External_ID_Field, Boolean



UpsertResult[] Database.Upsert(sObject[] recordsToUpsert, Schema.SObjectField External_ID_Field, Boolean