You need to sign in to do that
Don't have an account?
ramakoti reddy
whenever new record is created into Account object , before this new record is inserted delete the accounts with the same name.
give trigger code
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Please try the below code :
trigger accountrecords on Account (before insert)
{
List<String> myname=new List<String>();
for(Account a:trigger.new)
{
myname.add(a.name);
}
List<Account> myAccountList = new List<Account>();
myAccountList = [select id,name from Account where name in:myname];
system.debug('myAccountList'+myAccountList);
if(myAccountList != Null && myAccountList.size()>0)
{
delete myAccountList;
}
}
Hope this helps.
Thank You
Ajay Dubedi
Try this code Its working fine.
if you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay
There might be a case where you have a chance of updating the account name with the same name of another accounts. So it would be better if you also add before update in the trigger.
Thanks,
Sowmya