Posts

Showing posts with the label error

SFDC Issue in Runtime engine while bulk DML operation

Image
Salesforce Issue in partial record processing in bulk DML operation Here we will go through the issue related to partial record processing in bulk DML operations for example. Data loader, or database.insert( listSobject, false ). What is partial update? To understand the issue, first let’s understand partial update. Suppose we try to insert 5 records into Lead object and 1 fails 4 succeeds. This is called partial records processing in bulk DMLs. Scenario Let’s execute a scenario and prove that there is an issue with Salesforce partial record processing . Suppose we have a trigger as shown below. This sets the email field for all the newly inserted leads. 2.         Now suppose we insert below listed leads using data loader. Since we know that Company is mandatory on lead object, So last lead ‘Lead10’ should fail and all other should be successfully inserted. Also for success full leads email id should be set to ‘testemail@domain.co...

Too many batch retries in the presence of Apex triggers and partial failures.

Too many batch retries in the presence of Apex triggers and partial failures If you write and execute batch scripts then some time you might end up with this error, which may be difficult to understand. However proper explanation is given in the Salesforce documentation as below. Bulk DML Exception Handling Exceptions that arise from a bulk DML call (including any recursive DML operations in triggers that are fired as a direct result of the call) are handled differently depending on where the original call came from: When errors occur because of a bulk DML call that originates directly from the  Apex  DML statements, or if the  all_or_none  parameter of a database DML method was specified as true, the runtime engine follows the “all or nothing” rule: during a single operation, all records must be updated successfully or the entire operation rolls back to the point immediately preceding the DML statement. When errors occur because of a bulk DML call that ...

Salesforce trigger hell-1

Problem Many a time we see that the errors added by trigger's, are being shown to user in the below format, which are not user friendly and user's complain about that. Error: Invalid Data.  Review all error messages below to correct your data. Apex trigger validateLastname caused an unexpected exception, contact your administrator: validateLastname: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, no child allowed: Trigger.validateLastname: line 6, column 1 Root cause Whenever error with the line number is shown to user, you can be sure that this is un-handled exception. And it comes basically when you have fired another DML inside any trigger, and that DML is failed.  Let's understand this by scenario. Scenario  Let's assume that User is trying to save a record of OBJ1 from User interface. and you have written a trigger on OBJ1, which on certain cond...