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
Naganjaneya Lakshman TadepalliNaganjaneya Lakshman Tadepalli 

Question Regarding Triggers Development

In our project there are 2 objects with parent child relationship(Lookup relationship) between ORDER and ORDER DETAILS, in ORDER object there is field called Status having picklist values(New, Processed
and Completed), here the requirment is when ever the status is changed to Processed then an ORDER DETAIL record should be created for the corresponding record in the ORDER object. Can anyone help me with code 
to implement the trigger of above scenario?
Best Answer chosen by Naganjaneya Lakshman Tadepalli
saikrishna.Gsaikrishna.G
Trigger createchildobj on  ORDER(after Insert,after update){
list<OrderList> ordlist=new list<OrderList>();
for(Order ord:[SELECT id,status From Order WHERE status='Processed' and Id =:Trigger.New]{
 OrderDetail orddtl=new OrderDetail();
orddtl.Name=ord.Name;
ordlist.add(orddtl);
//Try to map all mandatory fields in child object here 
}
insert ordlist ;
}

}