You need to sign in to do that
Don't have an account?
i have created a a trigger but need a testmethod for it. Helppppppp.
Hi, i'm fairly new to the apex world, the below trigger works fine on the sandbox but in order to deploy it i need a testmethod for it. it would be appreciated if someone could help create a test method for it.
thanks in advance.
trigger CheckDuplicateAccountOnPhone on Account (before insert) {
Account[] accs = Trigger.new;
for (Account a:accs){
Integer hits;
String matchCond = a.phone;
System.debug(matchCond);
hits = [SELECT count() FROM Account WHERE phone = :matchCond];
System.debug(hits);
if (hits>0)
{
trigger.new[0].addError('Account already exists in Database, Please Contact Your Admin To Give you access to it. ');
}
}
}
Here is a lead dedup example that is similar. And here is the corresponding test method. Perhaps this can help you form yours.
Hope that helps,
Sati
All Answers
Here is a lead dedup example that is similar. And here is the corresponding test method. Perhaps this can help you form yours.
Hope that helps,
Sati
The example given by shillyer is good for two reasons:
thanks John/Shillyer, i end up using What Shiller referred me to and changed obviously from the lead object to the account object and checked on phone instead of email.
Really appreciate your help, thanks again.