I have a list of 1132 records and the record at 646 breaks and threw an exception when it tries to convert a invalid string to double. And the code halts and my pageblocktable displays 645 records. Is that possible to continue the execution after an exception thrown just omitting the error records in the way?
In the below screen shot, it stops at 645th record though it is having 1132 in total.
Attribution to: Bforce
Possible Suggestion/Solution #1
Not sure if you are using a wrapper class or not but why not just build the pageBlockTable list within a for loop
that has a try catch
- if an exception, the row in error is ignored
List<Account> aList = new List<Account> ();
for (Account a : [select id, name, fooStringFld__c from Account])
try {
Account workA = new Account();
workA.doubleFld__c = a.fooStringFld__c; // your string conversion here
workA.fldY__c = // other fields as needed
aList.add(workA);
}
catch(Exception e) {//do nothing or build up a list of errors for later resolution}
<apex:pageBlockTable value="{!aList}" var="a">
... columns
</apex:pageBlockTable>
Attribution to: cropredy
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34012