Skip to content

Commit

Permalink
Created a new branch and added the the DMLOptioons instance again
Browse files Browse the repository at this point in the history
  • Loading branch information
chininchu authored and aheber committed Oct 8, 2024
1 parent 65c8e97 commit 41e5aa2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dlrs/main/classes/RollupService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,20 @@ global with sharing class RollupService {
masterRecords.set(outerIndex, masterRecords.get(indexOfMin));
masterRecords.set(indexOfMin, temp);
}
// Create DmlOptions instance
Database.DMLOptions dml = new Database.DMLOptions();

// Allow save even if duplicates are detected
dml.DuplicateRuleHeader.allowSave = true;

// Run as current user to enforce sharing rules
dml.DuplicateRuleHeader.runAsCurrentUser = true;

// Apply DmlOptions to each record
for (SObject record : masterRecords) {
record.setOptions(dml);
}

try {
return Database.update(masterRecords, allOrNothing);
} catch (DMLException e) {
Expand Down

0 comments on commit 41e5aa2

Please sign in to comment.