function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HoysalaHoysala 

please help me, am struck. i want to avoid dplicate ratings,subratings,and country...? am not getting done with duplication rules

Best Answer chosen by Hoysala
NagendraNagendra (Salesforce Developers) 
Hi Suraj,

Sorry for this issue you are facing.

May I suggest you please give a try by using matching rules which might help.

Matching Rules are used to identify duplicate records within Salesforce.
When the matching rule is run, it compares the record’s match keys against those for existing records. Then, for records that share the same match keys, the matching rule uses matching algorithms to compare fields and determine how closely the fields, and ultimately the records, match. If two records’ don’t share the same match keys, they are not considered duplicates and the matching algorithms will not even be applied to them.

For more information please refer to below links. Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra

All Answers

Raj VakatiRaj Vakati
I have a simple option .. 

1 . Create a formual field call unique Combined and API name is unique_combined__c ( formula will be rating+subrating+county ) and retunr type is text 

user this formual in trigger to get the duplicate codes 

try this sample code
 
trigger AccountDuplicateTrigger on Account (before insert,before update) {

    list<string> uniqyeName=new list<string>();
    for(Account accountVar:trigger.new)
    {
        accountNames.add(accountVar.Rating+accountVar.subrating__c+accountVar.country__c);
    }
    list<Account> listOfDuplicateAccounts=[select id,name from Account where unique_combined__c  in :uniqyeName];
    for(Account account:trigger.new)
    {
        if(trigger.isInsert){
        if(listOfDuplicateAccounts.size()!=0)
        {
            account.addError('Account already exists with this name');
        }
        }
        if(trigger.isUpdate)
        {
           for(Account oldaccount :trigger.old)
           {
               if(account.Name!=oldAccount.Name && listOfDuplicateAccounts.size()!=0)
               {
                   account.addError('Account already exists with this name');
               }
           }
        }
    }
    

}

 
NagendraNagendra (Salesforce Developers) 
Hi Suraj,

Sorry for this issue you are facing.

May I suggest you please give a try by using matching rules which might help.

Matching Rules are used to identify duplicate records within Salesforce.
When the matching rule is run, it compares the record’s match keys against those for existing records. Then, for records that share the same match keys, the matching rule uses matching algorithms to compare fields and determine how closely the fields, and ultimately the records, match. If two records’ don’t share the same match keys, they are not considered duplicates and the matching algorithms will not even be applied to them.

For more information please refer to below links. Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
This was selected as the best answer
HoysalaHoysala
Thanku Raj vakati and Nagendra. guys  here are getting nice help from you bith..