You need to sign in to do that
Don't have an account?
sales@myvarma
hey help me
hey i want to create account records when every lead converted but should automatically check for duplicates if it was duplicate account with "name" should update all the data in to old account record only, instead of creating new account record.
i tried my best but not working
i tried my best but not working
You can do it with trigger on lead..
like if lead is converted here is I wrote code for you..
trigger onLead on Lead (before update)
{
List<Lead> lstLead = new List<Lead>();
lstLead = (List<Lead>)Trigger.New;
set<String> setAccName = new set<String>();
for( Lead currentLead : lstLead ){
if (currentLead.IsConverted){
setAccName.add( currentLead.Company );
}
}
List<Account> lstAccount = new List<Account>();
List<Account> lstAccountToUpdate = new List<Account>();
lstAccount = [ SELECT ID,Name FROM Account WHERE Name In: setAccName];
if( !lstAccount.isEmpty() && lstAccount.size() > 0 ){
for( Account acc : lstAccount ){
for( Lead leadObj : lstLead ){
if( acc.Name == leadObj.Company ){
Account accToUpdate = new Account();
accToUpdate.Id = acc.Id;
accToUpdate.Name = leadObj.Company;
accToUpdate.Industry = leadObj.Industry;
accToUpdate.AnnualRevenue = leadObj.AnnualRevenue;
accToUpdate.BillingCity = leadObj.City;
accToUpdate.BillingState = leadObj.State;
accToUpdate.BillingCountry = leadObj.Country;
accToUpdate.BillingPostalCode = leadObj.PostalCode;
accToUpdate.Rating = leadObj.Rating;
accToUpdate.NumberOfEmployees = leadObj.NumberOfEmployees;
accToUpdate.Phone = leadObj.Phone;
accToUpdate.Fax = leadObj.Fax;
accToUpdate.Website = leadObj.Website;
lstAccountToUpdate.add(accToUpdate);
}
}
}
}
Database.update(lstAccountToUpdate);
}
Hi Pradeep,
As per my understanding, we can only acheive it through custom Convert button. When you click on the custom Convert button we need to write a code to convert it manually. I do not think we can safely achieve it through Trigger.
Thanks
Brahma