+ 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
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();
//Try to map all mandatory fields in child object here 
insert ordlist ;