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
Bayarea 101Bayarea 101 

Custom object issue

Hi there,
I had created a custom object ABCD.
I had created a look up field on this object for Leads and account. I have this object present as related list on Leads and accounts. 
My issue is when i populate this cutom object on Lead page and trys to convert this lead this custom object info don't flow to related list present at account object.
Is there is way i can do this?
what i wanted to do is when this custom object information is populate don lead level and lead has been converted this custom object informtion should be displyed on Account page also as related list.
Praveen PosaPraveen Posa
Hi Bayarea,

  Consider a custom object Movie (Movie__c), in that two lookup fields,
1. Account__c - to Account object 
2. Lead__c  - to Lead Oject 

We need to write a trigger on lead object. Find the Trigger below and let me know your comments on this. In your case Movie object should be ABCD object. 

trigger myCustomLead on Lead (after update) {

Map<Id,Id> leadAccMap = new Map<Id,Id>();

for(Lead L : trigger.new)
{
   if(L.isConverted){
       leadAccMap.put(L.Id,L.convertedAccountId);
   }

}

List<Movie__c> movieList = [Select id,Account__c,Lead__c from Movie__c where Lead__c in: leadAccMap.keySet()];

for(Movie__c movie: movieList){
   movie.Account__c = leadAccMap.get(movie.lead__c);
}
 
 update movieList;
}

  Please let me know if its work for you, and please mark it as solved.