I have a fairly complex trigger that upserts accounts when records of a 2nd object are inserted or updated.

We also have a duplicate rule in Account that is set to detect dupes but "Allow" if the user wants to. We really only want the GUI users to get stopped, since these 2nd objects' records are the source of truth and any dupes are ok if this trigger inserts them.

Ideally, I know that if I am doing inserts or updates I can set DMLOption.DuplicateRuleHeader to allowSave = true. However, this option is not present for upserts.

Does anybody know a way to get this done without having to separate the DMLs into update and insert and make two calls? (I am using the ID for the upserts so it wouldn't be the end of the world, but I am trying to keep the DMLs down)

1 Answer 1


Unfortunately, you can't combine the two, so you'll have to take the extra DML hit. Like you said, it's likely not the end of the world, but it is a limitation you'll have to live with.

  • Ugh. I was kind of expecting that you, Adrian or David would have a magic wand I could wave over this. I'm going to be close to DML limits in this trigger. Commented Jun 24, 2019 at 19:55
  • 1
    @SebastianKessel There's a lot of tricks for optimizing DML operations, this just happens to not be one of them 😢.
    – sfdcfox
    Commented Jun 24, 2019 at 20:06

You must log in to answer this question.

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