0

I have a use case where i have to upsert records through trigger matching external id. i am using below in trigger for dml

Database.upsert(listToInsert,plan_product__c.Fields.External_Product_Key__c, true); Where External_Product_Key__c is the external keys defined on plan_product__c objects.

I was expecting above dml statement to keep trying upserting for all objects with matching external keys, but its throughing error even in case when external keys exist for products. All records including products where external exist are errored out. Any Suggestion are welcome.

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Adrian Larson
    Commented Feb 7, 2017 at 23:08

1 Answer 1

1

I think you are not understanding what the allOrNone flag is doing.

allOrNone

Type: Boolean

The optional allOrNone parameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

2
  • Its working as expected, could you please guide me when we run the dataloader with 100 records for example, i would like to those records to go into error.csv file generated by dataloader stating external id is missing. Commented Feb 7, 2017 at 22:48
  • 2
    @DavidMycka - If using data loader any record(s) that fail will be output to the errors csv. Have you actually tried it?
    – Eric
    Commented Feb 7, 2017 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .