You need to sign in to do that
Don't have an account?
hybin joseph 2
I have just started off learning triggers and I wrote a trigger but it is not working please help...
I have just started off learning triggers and I wrote a trigger but it is not working.Please find the trigger I wrote below.Let me know what is wrong on this one :
trigger OpportunityCreator on Account (After Insert) {
list<Opportunity> LstOpps = new list<Opportunity>();
for(Account acct : Trigger.new){
Opportunity Opps = new Opportunity();
Opps.StageName = 'Open';
Opps.Name = 'New Opportunity';
Opps.CloseDate = Date.newinstance(2017,02,21);
LstOpps.add(Opps);
}
Insert LstOpps;
}
trigger OpportunityCreator on Account (After Insert) {
list<Opportunity> LstOpps = new list<Opportunity>();
for(Account acct : Trigger.new){
Opportunity Opps = new Opportunity();
Opps.StageName = 'Open';
Opps.Name = 'New Opportunity';
Opps.CloseDate = Date.newinstance(2017,02,21);
LstOpps.add(Opps);
}
Insert LstOpps;
}
Your trigger is working fine, but the problem is you are not relating the new inserted opportunity with Account
Please try below code
Let me know, if it works,
Best Regards,
Dayakar
All Answers
Your trigger is working fine, but the problem is you are not relating the new inserted opportunity with Account
Please try below code
Let me know, if it works,
Best Regards,
Dayakar