Print this page

DuplicateRecordItem rows not available in Apex

Knowledge Article Number 000240380
DuplicateRecordItem is not populated while in the current transaction of creating a duplicate for an entity (insert/update).

For example, if you had a duplicate rule in place for an entity with only 'report' check (so it does not error on creation) then DuplicateRecordItem will be populated with duplicate rows - but only AFTER the transaction in which the duplicate rows have been created has completed.

This is because the action is asynchronous and the DuplicateRecordItem can only be referred to after it is committed or the transaction is complete.
Resolution Do not attempt to use DuplicateRecordItem to validate if duplicates were inserted in the same transaction, as it does not give the expected results.

Similarly, do not use it in Apex Tests, as for the same reason it results in no rows.

promote demote