function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eran VizelEran Vizel 

Polymorphic field on DuplicateRecordItem object

Hi guys,

Question regarding the new duplicate management. I'm trying to place a trigger on creation of DuplicateRecordSet, so that whenever there's a dupe match between account and lead, some code will run. Problem is I want to query and look on specific fields on DuplicateRecordItem only whenever it's connected to lead. The field "record" on DuplicateRecordItem is polymorphic and can be lookup to any existing object in the system. Therefore, when I try to query something like record.Related_Account__c (Related_Account__c is a field we have on Lead), it's not recognized and I cannot save the code.
Salesforce support says the TYPEOF function is not operable in production environments, so that's not a solution.

Please advise,
Many thanks,
Eran
Jason Curtis NBSFDGJason Curtis NBSFDG
Hmm, you can find the object by deconstructing the record ID, see: How to find Object Type from Record ID Prefix (https://help.salesforce.com/apex/HTViewSolution?urlname=How-to-find-Object-Type-from-Record-ID-Prefix&language=en_US)