You need to sign in to do that
Don't have an account?
Gateway Bikes Group4
/* Write a trigger that automatically creates an Account whenever a Lead is created. The Account be named after the last name of the Lead*/
/* Write a trigger that automatically creates an Account whenever a Lead is created. The Account be named after the last name of the Lead*/
trigger Accountcreate on Lead(after insert){
for(Lead ld:Trigger.new){
Account acc= new Account();
acc.Name=ld.Lastname;
insert acc;
}
}
@isTest
private class AccountcreateTest {
@isTest static void Accountcreate() {
// Implement test code
Lead ld = new Lead();
ld.LastName ='Creed';
ld.FirstName='Apollo';
ld.Company ='Rocky';
Insert ld;
}
}
trigger Accountcreate on Lead(after insert){
for(Lead ld:Trigger.new){
Account acc= new Account();
acc.Name=ld.Lastname;
insert acc;
}
}
@isTest
private class AccountcreateTest {
@isTest static void Accountcreate() {
// Implement test code
Lead ld = new Lead();
ld.LastName ='Creed';
ld.FirstName='Apollo';
ld.Company ='Rocky';
Insert ld;
}
}
All Answers
Test CLass
Yeah It works fine.
But why it also works fine when we use in Before Insert.
trigger CreateAccounts on Lead (before insert) {
For(lead l:Trigger.new){
Account a;
a=new Account(Name=l.LastName);
insert a;
}
}
It is working when I execute the above code.