function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hiral Patel 25Hiral Patel 25 

create new account with type=customer direct and industry=banking and new opportunities record will be created using trigger

create  new account with type=customer direct and industry=banking and new opportunities record will be created using trigger
 
Best Answer chosen by Hiral Patel 25
Hiral Patel 25Hiral Patel 25
i saw this error :Variable does not exist: AccouuntId

trigger triggeraccount0209 on Account (after insert) 
{
list<Opportunity> olist = new list<Opportunity>();
if(trigger.isafter && trigger.isinsert)
{
for(Account a: trigger.new)
{
if(a.type=='customer direct ' && a.industry=='banking')
{
Opportunity o= new Opportunity();
o.AccouuntId= a.id;
//populate all the necessary fields
olist.add(o);
}
}
if(olist.size()>0)
{ insert olist;}
}
}
 

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Hiral,

You can try checking the below code and modify it to match your scenario:
 
trigger acctri on account(after insert)
{
list<Opportunity> olist = new list<Opportunity>();
if(trigger.isafter && trigger.isinsert)
{
for(Account a: trigger.new)
{
if(a.type=='customer direct ' && a.industry=='banking')
{
Opportunity o= new Opportunity();
o.AccouuntId= a.id;
//populate all the necessary fields
olist.add(o);
}
}
if(olist.size()>0)
{ insert olist;}
}
}

Please do note that the above is a sample code.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Hiral Patel 25Hiral Patel 25
i saw this error :Variable does not exist: AccouuntId

trigger triggeraccount0209 on Account (after insert) 
{
list<Opportunity> olist = new list<Opportunity>();
if(trigger.isafter && trigger.isinsert)
{
for(Account a: trigger.new)
{
if(a.type=='customer direct ' && a.industry=='banking')
{
Opportunity o= new Opportunity();
o.AccouuntId= a.id;
//populate all the necessary fields
olist.add(o);
}
}
if(olist.size()>0)
{ insert olist;}
}
}
 
This was selected as the best answer
ANUTEJANUTEJ (Salesforce Developers) 
sorry try changing it to AccountId. 

If this helps can you mark this as best answer so that it can be useful for others in the future.