You need to sign in to do that
Don't have an account?
Div403
How to avoid query in inside for loop?
trigger DuplicateAccountNameCountryCheck1 on Account (before insert, before update)
{
For(Account a:Trigger.New)
{
List<Account> acc=[SELECT Id, Name FROM Account WHERE Name=:a.Name AND BillingCountry=:a.BillingCountry];
if(acc.size()>0)
{
a.addError('You are not allow to create duplicate Account Name with the same Country');
}
}
}
{
For(Account a:Trigger.New)
{
List<Account> acc=[SELECT Id, Name FROM Account WHERE Name=:a.Name AND BillingCountry=:a.BillingCountry];
if(acc.size()>0)
{
a.addError('You are not allow to create duplicate Account Name with the same Country');
}
}
}
All Answers
But, I am facing the below error
execution of BeforeUpdate caused by: System.StringException: Invalid id: US