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
mukesh guptamukesh gupta 

Lead object Field Update By Child Object

Hi Expert

I want to update Lead object field by child object of Lead, but i am not able to get relation.

Please suggesy
bhanu_prakashbhanu_prakash
Hi Mukesh,
Mark as best answer, If it resloves !!
you can use these sample trigger 
trigger updateChild_Object1 on  Child_Object (after insert){
    List<Child_Object> lstConUpdate = new List<Child_Object>();
    set<Id> sAccId = new set<Id>();
    for(Child_Object con: trigger.new){
        sAccId.add(con.LeadId);
    }
    List<Lead> lstLead = [select id, Address_1__c, (select id,Address_1__c from Child_Objects) from Lead where id IN: sAccId];
    for(Lead acc: lstLead){
        for(Child_Object con: acc.Child_Objects){
            con.Address_1__c = acc.Address_1__c;
            lstConUpdate.add(con);
        }
    }
    if(lstConUpdate.size() > 0){
        update lstConUpdate;
    }   
}

Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com​ (https://www.forcelearn.com)
Raj2019ssRaj2019ss
Hi mukesh gupta,
You can create Self relationship. Create a Lookup and related to Lead.

Let me know if you have any issues.
mukesh guptamukesh gupta
Hi,

I have Lead Lookup filed on custom object (Item) that's is child of Lead, I want to get child Item's name on Lead object. but I am not able to get relation. 

Please Suggest