Bulkify DuplicateRecordItem trigger when inserted by Automated Process - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
20  Points
Open
Idea has been posted. Give it an upvote or downvote.

Bulkify DuplicateRecordItem trigger when inserted by Automated Process

Campaigns & Leads

I have a trigger built on the DuplicateRecordItem object. In order to meet the requirements of the product we're building, I had to do some funkiness to get around SOQL and DML limit issues. Why? Well, when the Automated Process user finds duplicate records, the DuplicateRecordItems don't seem to be inserted in bulk. This seems like a flaw to me that should be improved.

If I'm inserting 5 leads and 5 duplicates are found, I'd expect to see a debug log where 5 DuplicateRecordItems are being inserted by the Automated Process user. This is happening, but one-by-one in the same execution context.

My debug log looks something like this (truncated to remove business logic):
17:25:54.0 (672964)|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS
17:25:54.0 (1855848)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (201951200)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (278330109)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001Atx8]
17:25:54.0 (595800979)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001Atx8]
17:25:54.0 (656795028)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (666779292)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (696109353)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001Atx9]
17:25:54.0 (720758546)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001Atx9]
17:25:54.0 (748951344)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (753501365)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (789856188)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001AtxA]
17:25:54.0 (812664269)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001AtxA]
17:25:54.0 (837110798)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (840939576)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (874777343)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001AtxB]
17:25:54.0 (895501197)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001AtxB]
17:25:54.0 (921262665)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (925065733)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event BeforeInsert for [new]
17:25:54.0 (950455245)|CODE_UNIT_STARTED|[EXTERNAL]|01q36000001GnM4|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001AtxC]
17:25:54.0 (971136910)|CODE_UNIT_FINISHED|LAM_DuplicateRecordItemTrigger on DuplicateRecordItem trigger event AfterInsert for [0GL36000001AtxC]
17:25:54.0 (991983991)|CODE_UNIT_FINISHED|TRIGGERS

Salesforce always advocates for never doing DML and SOQL in for loops... but it seems as though we have a loop here that is beyond our control. If I need to do any queries or DML in this trigger, I had better be very careful because if 151 records are being inserted then I'm suddenly out of DML calls just by doing one in the trigger.

Merge Idea · Flag

  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

No results found.

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.