Private ReadonlycandidateCandidate org records grouped by SObject type and lookup scope
Private ReadonlyconsumedOrg record IDs already matched to a datapack record
Private ReadonlyloggerOptionalorgOptional store of extracted org records; when set the candidate rows for extracted types are resolved from the store instead of through org queries. Set by the DatapackComparer when bulk extraction is enabled.
Private ReadonlyrecordPrivate ReadonlysalesforcePrivatebuildIndex the rows of a candidate group by the canonical form of the values of the specified fields; mirrors the record key built in findMatch so a row and the record it matches produce the same key.
PrivatefindFind the first unconsumed candidate row in the group that matches the record on all compared fields.
Candidates are located through an index on the canonical form (OrgRecordComparer.canonicalMatchValue) of the compared values -- the same approach used by the matching key lookups -- and each candidate is verified with OrgRecordComparer.fieldEquals so the exact matching semantics are preserved. Values that OrgRecordComparer.fieldEquals can match fuzzily (date-like strings) or that have no exact canonical form are excluded from the index key and only verified per candidate; records without any indexable value fall back to comparing against every candidate row.
Record to match
Candidate group with the queried org rows
Fields to compare
Cache of row indexes per group and field shape shared across the match requests of a single call
PrivategetPrivategetGet the record values for all fields that exist in the target org; used to report the record data that is missing in the target org.
PrivategetGet the fields of a record that are compared against org data to establish record identity. Unlike the field comparison of an already matched record, create-only fields (e.g. master-detail relationships) are included: they cannot be updated but they are set on insert and often are the only fields that discriminate between sibling records. Fields that do not exist in the target org, that cannot be written at all (formula, auto-number) or that contain binary data are excluded.
PrivategetBuild a lookup filter from the filterable field values of a record; used as fallback to locate
standalone records without matching key and without parent references. Returns undefined when
none of the record fields can be filtered on.
PrivategetPrivategetPrivategetBuild a lookup filter from the resolved parent references of an embedded record; returns undefined
when the record has no resolved parent references.
PrivategetDetermines if a record contains data that prevents a reliable full comparison against org data;
returns a description of the blocking condition or undefined when the record can be fully compared.
Get the IDs of the org records in the specified scopes that are not matched to a datapack record. Reuses the org records already queried for matching when available; scopes that were not queried yet are queried in a single batched lookup. Used by the deployment to delete only the unmatched org records of a parent while preserving the records that are matched (and thus in sync) with the datapack.
SObject type of the scopes
Scope filters, i.e. { parentField: parentId } per parent
OptionalcancelToken: CancellationTokenAn optional cancellation token to abort the org lookups
Per scope (in input order) the org record IDs that are not matched to a datapack record
Get all org records queried in the scope of a datapack (child records of a deployed parent) that are not matched to a datapack record; such records are deleted when the datapack is deployed.
The unmatched org records with the queried field values
Match datapack records without matching key against org data by querying the org records in the same scope (child records of the same parent) and comparing all comparable fields.
Records that match consume the matched org record and report an inSync outcome including the matched
record ID; records without an org match report a missing outcome with the record data that is missing.
The caller decides how to act on the outcomes (e.g. skip the record in a deployment or report it).
Records without an outcome were not matched due to a cancellation and should be treated as not matched.
Records to match; parent references must be resolved before matching
Optionaloptions: RecordMatchOptionsOptions controlling the matching behavior
OptionalcancelToken: CancellationTokenAn optional cancellation token to abort the org lookups
Match outcome per record keyed by record source key
PrivatematchOptionaloptions: RecordMatchOptionsOptionalcancelToken: CancellationTokenPrivatequeryQuery the org records for candidate groups that have not been queried yet or require additional fields; queried rows are merged into the group by record ID. Rows are assigned to their group(s) through an index on the canonical form of the scope values -- scopes with values that cannot be indexed exactly are compared per row -- and each assignment is verified with OrgRecordComparer.recordMatches to preserve the exact matching semantics.
OptionalcancelToken: CancellationTokenRelease the record IDs consumed by previous matches while retaining queried candidate rows. A deployment comparison calls this after building its result so the same matcher can subsequently be reused by the deployment's embedded-record purge without querying the org again.
Matches datapack records that cannot be identified through a matching key -- typically embedded child records which a deployment deletes and recreates -- against the records in the target org by comparing the record data. Records are located through their resolved parent references and compared field-by-field using OrgRecordComparer.fieldEquals; each org record can only be matched by a single datapack record.
The matcher is stateful: queried org records and matched record IDs are tracked across calls so subsequent matches (e.g. for records deeper in the datapack tree) do not match the same org record twice. Use one matcher instance per deployment or comparison.