2

I am using DuplicateResult Class to capture and display duplicate records. I am using this code snippet from the documentation: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Datacloud_DuplicateResult.htm My question is, what indicates what fields from the Contact object are included the matchRecord array? Is it the duplicate rules that define the fields for the query? I am attempting to add additional fields from the Contact object but get an error:

SObject row was retrieved via SOQL without querying the requested field: Account.State

5
  • 1
    there is no field Account.State - there is Account.BillingState or Account.ShippingState
    – cropredy
    Commented Sep 5, 2019 at 19:36
  • Thank you for catching that. I meant to say I can not access Account.BillingState, but yet I am able to access Account.BillingStreet.
    – Ivo Dimov
    Commented Sep 5, 2019 at 20:15
  • Do you have state and country pick lists enabled?
    – cropredy
    Commented Sep 5, 2019 at 20:45
  • No, the billingState and billingCountry are strings.
    – Ivo Dimov
    Commented Sep 5, 2019 at 21:02
  • Can you edit your post to include the specific fields you have in your compact layout? Commented Sep 6, 2019 at 14:26

2 Answers 2

2

It uses the object's primary CompactLayout. See the findDuplicates() documentation.

If the includeRecordDetails flag in DuplicateRuleHeader is set to false, findDuplicates() only returns the record IDs of the matching records. Otherwise, findDuplicates() returns all the fields specified in the primary CompactLayout associated with the target object

3
  • Thank you for the info. I have address field added in the compact layout. I am able to access Street, but get the error, when I try accessing state.
    – Ivo Dimov
    Commented Sep 5, 2019 at 19:22
  • I'm guessing that findDuplicates() will retrieve only the base object fields, not related object fields. Commented Sep 5, 2019 at 19:38
  • Thank you for the feedback. I am trying to get the base object fields. That is why I am confused as to why I can access the billing street, but not billing State. I thought this must be configured somewhere.
    – Ivo Dimov
    Commented Sep 6, 2019 at 12:10
1

So I think I figured it out.Under the DuplicateResult class there is a method called Datacloud.match. This method identifies the matching or different fields defined in the Matching Rule/Matching criteria. In other words, the only fields returned by the Duplicateresults are fields that are defined in the rules. You can not return a field which is not part of it. I included BillingState in the matching rules, and now I am able to access it.

You must log in to answer this question.

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