Skip to content

Commit

Permalink
Use DMLOptions to bypass duplicate rule exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
chininchu committed Sep 27, 2024
1 parent 3f37248 commit cfe546b
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 367 deletions.
15 changes: 14 additions & 1 deletion dlrs/main/classes/RollupService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,21 @@ global with sharing class RollupService {
masterRecords.set(outerIndex, masterRecords.get(indexOfMin));
masterRecords.set(indexOfMin, temp);
}

// Create DmlOptions instance

Database.DmlOptions dmlOptions = new Database.DmlOptions();

// Allows save even if duplicated are detected
dmlOptions.duplicateRuleHeader.allowSave = true;

// Bypass duplicate rules

// dmlOptions.duplicateRuleHeader.duplicateRuleBypassFlow = true;

try {
return Database.update(masterRecords, allOrNothing);
// Perform the update operation with Dmloptions
return Database.update(masterRecords, dmlOptions);
} catch (DMLException e) {
// Determine if the exception is due to parent record/s having been deleted
Boolean throwException = true;
Expand Down
33 changes: 23 additions & 10 deletions dlrs/main/lwc/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
{
"compilerOptions": {
"experimentalDecorators": true
},
"include": ["**/*", "../../../.sfdx/typings/lwc/**/*.d.ts"],
"paths": {
"c/*": ["*"]
},
"typeAcquisition": {
"include": ["jest"]
}
"compilerOptions": {
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"c/*": [
"*"
]
}
},
"include": [
"**/*",
"../../../.sfdx/typings/lwc/**/*.d.ts"
],
"paths": {
"c/*": [
"*"
]
},
"typeAcquisition": {
"include": [
"jest"
]
}
}
Loading

0 comments on commit cfe546b

Please sign in to comment.