function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger insertOpp on Account(After insert) { Opportunity op=new Opportunity(); op.Name='Google'; op.CloseDate=date.today().format(); op.StageName='Qualification'; insert op; }
trigger insertOpp on Account(After insert) { List<Opportunity> opplist=new List<Opportunity>(); for(Account acc:Trigger.new){ if(acc.<custom field name>!=null && acc.<custom field name>==''){ Opportunity op=new Opportunity(); op.Name='Google'; op.CloseDate=date.today().format(); op.StageName='Qualification'; opplist.add(op); } } insert opplist; }
trigger insertOpp on Account(After insert) { List<Opportunity> opplist=new List<Opportunity>(); for(Account acc:Trigger.new){ if(acc.Property_Address_from_Survey__c!=null && acc.Property_Address_from_Survey__c==''){ Opportunity op=new Opportunity(); op.Name=acc.Property_Address_from_Survey__c; op.CloseDate=date.today().format(); op.StageName='Qualification'; opplist.add(op); } } insert opplist; }
thanks,
RAmesh
You need to put an if condition so that this trigger fires only when a particular Account custom field is populated something as below
{
List<Opportunity> opplist=new List<Opportunity>();
for(Account acc:Trigger.new){
if(acc.Property_Address_from_Survey__c!=null && acc.Property_Address_from_Survey__c==''){
Opportunity op=new Opportunity();
op.Name=acc.Property_Address_from_Survey__c;
op.CloseDate=date.today().format();
op.StageName='Pre-Qual';
opplist.add(op);
}
}
insert opplist;
}
Can you help?
trigger insertOpp on Account(After insert)
{
List<Opportunity> opplist=new List<Opportunity>();
for(Account acc:Trigger.new){
if(acc.Property_Address_from_Survey__c!=null && acc.Property_Address_from_Survey__c==''){
Opportunity op=new Opportunity();
op.Name=acc.Property_Address_from_Survey__c;
op.CloseDate=date.today().format();
op.StageName='Pre-Qual';
opplist.add(op);
}
}
insert opplist;
}
op.Stagename='Pre-Qual'
Stagename does not have the value Pre-Qual please add the picklit value in Opportunity object.
or try the below.
thanks,
Ramesh