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
Niharika GoudNiharika Goud 

I have three Objects Contact,Loan__c,Employe__c ; Loan__c is child Object to Contact and Employe__c'My Question is Employe__c object one field copy to Contact Object one field using trigger

Hai,

I am New to SFDC

Please Help Me Urgent 
Niraj Kr SinghNiraj Kr Singh
Hi Saraswathi
Check with the this trigger:
// I consider, this is your field "TestFIeld__c" to move value from Employe__c to Contact. You can change.

Trigger updateContactField on Loan__c (after insert, before Update) {
    Set<Id> setLoadIds = new Set<Id>();
    List<Contact> updateContact = New List<Contact>();
    for(Loan__c objLoan : Trigger.new) {
        setLoadIds.add(objLoan.Id);
    }
   
    For(Loan__c objLoan : [Select Id, Employe__c, Employe__r.TestField__c, Contact, Contact.Id, Contact.TestField__c FROM Loan__c WHERE Id IN:setLoadIds]) {
        if(objLoan.Employe__c != NULL && objLoan.Contact != NULL) {
            updateContact.add(New Contact(Id = objLoan.Contact.Id, TestFIeld__c = objLoan.Employe__r.TestField__c));
        }
    }
    
    if(!updateContact.isEmpty()) {update updateContact;}
}