You need to sign in to do that
Don't have an account?
Mona Kawale
//If I am inserting account then it should make count with //respect to its number of same account with same name count in Org.
//If I am inserting account then it should make count with
//respect to its number of same account with same name count in Org.
public class CountDuplicateAccount {
public static void myMethod(List<Account> newList){
integer count=0;
set<id> ids=new set<id>();
for(account ac:newlist){
ids.add(ac.id);
}
map<id,Account> oldlist = new map<id, account>([select id, name from Account where id In: ids]);
if(!newList.isempty()){
for(Account acc:newList){
if(acc.name==oldlist.get(acc.id).name)
count=count+1;
acc.Total_Duplicate_Account__c=count+1;
}
}
}
}
//respect to its number of same account with same name count in Org.
public class CountDuplicateAccount {
public static void myMethod(List<Account> newList){
integer count=0;
set<id> ids=new set<id>();
for(account ac:newlist){
ids.add(ac.id);
}
map<id,Account> oldlist = new map<id, account>([select id, name from Account where id In: ids]);
if(!newList.isempty()){
for(Account acc:newList){
if(acc.name==oldlist.get(acc.id).name)
count=count+1;
acc.Total_Duplicate_Account__c=count+1;
}
}
}
}
By using the below code you can show the count of duplicate Accounts on Visualforce Page. Here is the logic :-
VF Page :-
Controller Class :-
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan
Try this :- Reference :- https://developer.salesforce.com/forums/?id=9060G0000005l2yQAA
Thanks