How to ignore Duplicate Rule when commitWork for Account/Contact/Lead? #445
-
| 
         Hi, Salesforce implemented Duplicate Rules for Account/Contact/Lead. Database.DMLOptions allows us to ignore the duplicate rule and force insert into the db. Database.DMLOptions dml = new Database.DMLOptions(); When using Unit Of Work, how do I achieve the same? Thanks,  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| 
         G'day @briancodey.  When using the UnitOfWork, the default constructor creates the instance of the inner class  With that in mind, you would create your own  I hope this helps. Let us know if you have more questions.  | 
  
Beta Was this translation helpful? Give feedback.
G'day @briancodey. When using the UnitOfWork, the default constructor creates the instance of the inner class
SimpleDML. Thefflib_SObjectUnitOfWorkclass relies on theIDMLinterface to dictate how DML operations will be handled.With that in mind, you would create your own
IDMLclass that sets theDMLOptionsthe way you need them, and then instantiate thefflib_SObjectUnitOfWorkusing its second constructor which acceptsIDMLas the second argument. For an alternate example of anIDML, refer to the other one present in the fflib_SObjectUnitOfWork class calledUserModeDML.I hope this helps. Let us know if you have more questions.