You need to sign in to do that
Don't have an account?
Merge requires a concrete SObject type: List<Account>
Hi i wrote this code and getting this error. what I wanted to do is there is checkbox field on account so when user checks that field then all its duplicate accounts have to be merged to this main account on which checkbox is enabled but I am getting this error :Merge requires a concrete SObject type: List<Account>
I didn't understand this. please help me Thanks in advance
This is my code
Public class MergeAcct{
Public static void invoke(list<account> accounts){
list<account> masterAcct=new list<account>();
for(Account a: accounts){
if(a.Merge__c==true){
masterAcct.add(a);
}
}
list<account> acclist=[select id, name, Merge__c from account];
for(account acc:masterAcct){
for(account dupacc:acclist)
{
if(acc.Name==dupacc.Name && dupacc.Merge__c==false){
Merge masterAcct dupacc;
}
}
}
}
}
Trigger
trigger mergetrig on Account (after insert, after update) {
MergeAcct.invoke(Trigger.new);
}
Apologies for the delay in the respose as I was trying many ways for the same and due to some customization in my personal org it got failed, Please check if below trigger logic works.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
How do we identify which record do we need to merge. I understand that with Merge__c = true then it should be merged with some Accounts. How do we know which accounts need to be merged.
Do we need to consider the Name or some field?
Thanks,
Hi,
On Account there is a merge field Merge__c (check box) if we check that then trigger should fire which will merge duplicate accounts (same name) and its associated contacts to the Main account, main account here is the one which has check box field.
Thank you
Thanks for confirmarion. If there are multiple account each account having diffenet values like one has Rating as Hot and other as Cold and other as Warm so in merged Account what should be value and how is that determined?
Thanks,
Hi praveen,
If there are different values then whatever main account has only that value should be taken.(Here the account with Merge__c field checked values are primary)
Thank you
Could someone please help me with this
Thank you
Apologies for the delay in the respose as I was trying many ways for the same and due to some customization in my personal org it got failed, Please check if below trigger logic works.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Hi praveen,
This worked and understood as well. You are awesome Thanks a lot