You need to sign in to do that
Don't have an account?
Karthik keyan
After creating account the oppty not created in trigger
I written the trigger code that after creating new account the oppty should be created automatically.But the account was created but oppty seems to be not created.Could you please check this code its suitable to create or need to change the code further.
trigger CreateAccountOppty on Account (before insert,before update)
{ List<Opportunity> acc = new List<Opportunity>();
for(Account acc1:Trigger.new)
{
if(acc1.Rating =='Hot' )
{
Opportunity oppty = new Opportunity ();
oppty.name= acc1.Name;
oppty.Opportunity_Status__c='Active';
oppty.StageName ='Prospecting';
oppty.CloseDate= date.today()+1;
acc.add(oppty);
}
insert acc;
}
}
trigger CreateAccountOppty on Account (before insert,before update)
{ List<Opportunity> acc = new List<Opportunity>();
for(Account acc1:Trigger.new)
{
if(acc1.Rating =='Hot' )
{
Opportunity oppty = new Opportunity ();
oppty.name= acc1.Name;
oppty.Opportunity_Status__c='Active';
oppty.StageName ='Prospecting';
oppty.CloseDate= date.today()+1;
acc.add(oppty);
}
insert acc;
}
}
You need need to use after trigger, I modified your code and check it.
Please make sure all the mandatory fields in opportunity need to assign the values else opportunity record will not be created. Let me know if still if you face problem.
All Answers
You need need to use after trigger, I modified your code and check it.
Please make sure all the mandatory fields in opportunity need to assign the values else opportunity record will not be created. Let me know if still if you face problem.
Thanks for the exact coding ,that created oppty record,but the oppty created is not under newly created account .So i cant find the oppty record in the newly created account page.How to correlated the account and Oppty to show created oppty under the account.
Thanks,
Kathikeyan