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
hari azmeera 8hari azmeera 8 

automatically create a record in object 2 when a new record is created in object 1

Sujit Anil NirkheSujit Anil Nirkhe

pseudo code

You can use trigger to do this.

Trigger t1 on Object1<after insert>
{
       List<Object2> lstO2 = new List<Object2>();
       for(Object1 o1: trigger.new){
       Object2 o2 = new Object2();
//assign fields on o2 
lstO2.add(o2);      
}
insert lstO2;
}

SarisfdcSarisfdc
Write a trigger on object 1 (after insert trigger)
And create logic to insert new record in the the object 2.
JyothsnaJyothsna (Salesforce Developers) 
Hi Hari,

Please check the below trigger.
 
// Automatically create an Opp when an Account is created
trigger CreateNewAccountOpprtunity on Account (after insert) {
List<Opportunity> opplst=new List<Opportunity>();
for(account a:Trigger.new ){
 Opportunity opp=new Opportunity ();
  opp.AccountId = a.Id;
  system.debug(opp);
  

 opp.Name=a.name;
  opp.Stagename ='Proposal/price quote';
 opp.closeDate=system.today()+30;
 opplst.add(opp);
 system.debug(opplst);
}
insert opplst;

  system.debug(opplst);

}

Hope this helps you!
Best Regards,
Jyothsna
RAVITEJA C 19RAVITEJA C 19
Hi  Jyothsna  
In my Requirement when a case is 'Escalated' Account screen will be populate to open UI.pls provide the code in trigger and process builder any thing.
Regards,
Raviteja