You need to sign in to do that
Don't have an account?
RarLopz
bypass duplicate rule
I have two active duplicate rules on Account in production .
Now when i am trying to deploy my code for merging duplicate accounts, the deployment fails for a class that already exists in production. If i disable the duplicate rule, the test class that I am trying to deploy will fail because it check for active duplicate rules.
I did some research and found a workaround as follows.
My question is, do i have to add this workaround in my test class or the main class. Thank you !
Database.DMLOptions dml = new Database.DMLOptions(); dml.DuplicateRuleHeader.AllowSave = true; Account duplicateAccount = new Account(Name='dupe'); Database.SaveResult sr = Database.insert(duplicateAccount, dml); if (sr.isSuccess()) { System.debug('Duplicate account has been inserted in Salesforce!'); }
Now when i am trying to deploy my code for merging duplicate accounts, the deployment fails for a class that already exists in production. If i disable the duplicate rule, the test class that I am trying to deploy will fail because it check for active duplicate rules.
I did some research and found a workaround as follows.
My question is, do i have to add this workaround in my test class or the main class. Thank you !
Database.DMLOptions dml = new Database.DMLOptions(); dml.DuplicateRuleHeader.AllowSave = true; Account duplicateAccount = new Account(Name='dupe'); Database.SaveResult sr = Database.insert(duplicateAccount, dml); if (sr.isSuccess()) { System.debug('Duplicate account has been inserted in Salesforce!'); }
Test method example
https://salesforce.stackexchange.com/questions/169601/test-class-for-trigger-on-duplicaterecorditem-object
All Answers
Do you mean I should put that code snippet in the man class?
And in test class, I should put the rey catch block when asserting the result?
Can you please give an example? Thanks!
Test method example
https://salesforce.stackexchange.com/questions/169601/test-class-for-trigger-on-duplicaterecorditem-object