You need to sign in to do that
Don't have an account?
Rafael Motta
Cases Mtching Rule by apex class
Good morning Trailblazers.
I would appreciate your help to clear my mind. I would like to create a duplication rule for cases, so the only option I think i need to create a class, the problem is that I am not a developer and I want to help my team because I no longer have pending.
he criteria are as follows.
For the same Customer (Person Account)
Case Status does not equal to Resolved or Closed
Order Number = Exact match
Case Reason = Exact Match
Error Message: Duplicate Case [Case Number (link possible?)].
A case is already opened against this exact Customer, Order Number, and Case Reason.
I could crate the select of fields but when i try to ser If sentence, i can save the field
public class LP_CheckMarketingCustomerOnly{
Set<Id> CasesIds = new Set<Id>();
public static void GetAllCases() {
// Esta Consulta funciona, la tomare como base
Account[] AllAccounts = [SELECT Id,(SELECT Id,Order_Number__c,Reason,Status FROM Cases) FROM Account LIMIT 3];
for (Account accounts : AllAccounts) {
//for(Case cases:accounts.Cases)
// System.debug('Account Id:'+accounts.Id+' Case Id:'+cases.Id);
//accounts.Marketing_Customer_Only__c=true;
}
System.debug('This is a update'+ AllAccounts);
//update AllAccounts;
//System.debug('This is a testing debug cases'+ AllAccounts);
}}
if you can guide me i apriciate
I would appreciate your help to clear my mind. I would like to create a duplication rule for cases, so the only option I think i need to create a class, the problem is that I am not a developer and I want to help my team because I no longer have pending.
he criteria are as follows.
For the same Customer (Person Account)
Case Status does not equal to Resolved or Closed
Order Number = Exact match
Case Reason = Exact Match
Error Message: Duplicate Case [Case Number (link possible?)].
A case is already opened against this exact Customer, Order Number, and Case Reason.
I could crate the select of fields but when i try to ser If sentence, i can save the field
public class LP_CheckMarketingCustomerOnly{
Set<Id> CasesIds = new Set<Id>();
public static void GetAllCases() {
// Esta Consulta funciona, la tomare como base
Account[] AllAccounts = [SELECT Id,(SELECT Id,Order_Number__c,Reason,Status FROM Cases) FROM Account LIMIT 3];
for (Account accounts : AllAccounts) {
//for(Case cases:accounts.Cases)
// System.debug('Account Id:'+accounts.Id+' Case Id:'+cases.Id);
//accounts.Marketing_Customer_Only__c=true;
}
System.debug('This is a update'+ AllAccounts);
//update AllAccounts;
//System.debug('This is a testing debug cases'+ AllAccounts);
}}
if you can guide me i apriciate
Greetings!
Are you getting any errors with the above code.I would suggest you to refer the sample code in the below thread for trigger to prevent the duplicate case record creation.
https://salesforce.stackexchange.com/questions/21912/trying-to-create-a-trigger-to-prevent-creation-of-duplicate-accounts
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
As far as I know, you need a trigger and a handler for this
NOTE: The code provided is an example. You'll need to review and make modifications for your organization.
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you