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
Manoprabha PalpandianManoprabha Palpandian 

how to write a code for child object picklist filed update in parent object

AbhinavAbhinav (Salesforce Developers) 
Hi Manoprabha,

you can take reference from below link to update child records when parent record is updated.

https://developer.salesforce.com/forums/?id=906F0000000AvgCIAS

Thanks!
Manoprabha PalpandianManoprabha Palpandian
Custom Object - AirTravel, Fields - Arrival and Departure Datatype- Picklist. Custom Object - Hotel, Fields - Check In Date and Check Out Date Datatype- Picklist. These two custom objects lookup with Registraton1__c. How to give Hotels and Airtravel lookupvalues in reagistration1__c. Pls Can you help me. how to write a code for this
Manoprabha PalpandianManoprabha Palpandian
please help me
Manoprabha PalpandianManoprabha Palpandian
Custom Object - AirTravel, Fields - Arrival and Departure Datatype- Picklist. Custom Object - Hotel, Fields - Check In Date and Check Out Date Datatype- Picklist. These two custom objects lookup with Registraton1__c. How to give Hotels and Airtravel lookupvalues in reagistration1__c. Pls Can you help me.
Suraj Tripathi 47Suraj Tripathi 47
Hi Manoprabha,

You can take reference from the below code:-
trigger updateParent on hotel__c(after insert,after update){
   map<id, hotel__c> hotelMap= new map< id, hotel__c>([select checkindate__c,checkoutdate__c,registration1__c from hotel__c where id IN: trigger.new]);
   set<id> sid= new set<id>();
    for(hotel__c hotel: trigger.new){
       if(hotel.registration1__c!=null){
          sid.add(hotel.registration1__c);//lookup field with AirTravel object
       }
    }
List<AirTravel__c> updateairtravel= new List<AirTravel__c>();
  List<AirTravel__c> airtravel= new List<AirTravel__c>();
  airtravel=[select arrival__c,departure__c from AirTravel__c where id IN: sid];
  for(AirTravel__c air: airtravel){
      for(hotel__c ho:hotelMap.values()){
        if(air.id==ho.registration1__c){
          air.arrival__c=ho.checkindate__c;
          air.departure__c= ho.checkoutdate__c;
          updateairtravel.add(air);
       }
    }
  }
 if(updateairtravel.size()>0){
   update updateairtravel;
  }
}
In case you find any other issue please mention. 
If you find your Solution then mark this as the best answer. 

 
Manoprabha PalpandianManoprabha Palpandian
without using trigger how to write a code