Timeline for Deploying an Apex Class for a Custom Button - Too Many DML Statements Error
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 1, 2013 at 15:49 | comment | added | Brandon | @MartinPeters - Your suggestion fixed my issue. Thanks for the help! | |
Dec 23, 2012 at 7:45 | history | tweeted | twitter.com/#!/StackSalesforce/status/282753797720272896 | ||
Dec 21, 2012 at 19:46 | comment | added | Mark Pond | The correct solution as noted below is to not to perform the delete operation within a loop of individual records, instead delete a list of records. The reason this is happening when you deploy this code into production is because there are more than 150 Case records in the production org which are being retrieved by your SELECT statement. You are then running into the 150 DML Statements limit while iterating and on the 151st delete, the exception is thrown. | |
Dec 21, 2012 at 9:31 | comment | added | Martin Peters | What apex API version are you using? It looks like you're deleting all cases in the system as part of the test case (because it looks like "delete obj;" is failing), that's absolutely not something you can do since it'll will inevitably fail once you have too many cases in the system. Use tests with @isTest(seeAllData=false) annotations whenever possible, this is possible for API v24 and later. Using this annotation, you don't have to delete anything, tests won't see your production data. | |
Dec 20, 2012 at 20:32 | review | First posts | |||
Dec 20, 2012 at 21:59 | |||||
Dec 20, 2012 at 20:29 | answer | added | Mohith Shrivastava | timeline score: 0 | |
Dec 20, 2012 at 20:19 | answer | added | Samuel De Rycke | timeline score: 2 | |
Dec 20, 2012 at 20:13 | history | asked | Brandon | CC BY-SA 3.0 |