Skip to content

Commit

Permalink
Merge 6db4cee into feature/786-add-global-bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 8, 2024
2 parents 495e352 + 6db4cee commit c3961a5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dlrs/main/classes/RollupService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1680,8 +1680,19 @@ 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;

dml.OptAllOrNone = allOrNothing;

try {
return Database.update(masterRecords, allOrNothing);
return Database.update(masterRecords, dml);
} catch (DMLException e) {
// Determine if the exception is due to parent record/s having been deleted
Boolean throwException = true;
Expand All @@ -1704,6 +1715,7 @@ global with sharing class RollupService {
return new List<Database.Saveresult>();
}
// Throw on as normal

throw e;
}
}
Expand Down

0 comments on commit c3961a5

Please sign in to comment.