You need to sign in to do that
Don't have an account?
advlgx
Updating converted lead ids with the new contact id in a child custom object...
Is it possible to initiate/write something where the child records of a custom object that has both a contactid and leadid fields in the record, get updated within or after the Salesforce Convert Lead process executes, with the new contactid that was created from the converted lead?
Yes, using either Apex Code or the API, you can programmatically call the ConvertLead operation and then update your custom object contactID field with the values from the ConvertLead result.
Hope that helps,
Sati
Not wanting to actually remove the existing ConvertLead process, is this something I would do with a trigger? In other words, what do you recommend as the process for invoking the custom code while maintaining the basic Convert Lead functionality in Salesforce?
Thanks
Did you ever figure this out? I'm having the same issue. I've tried a couple of different unsuccessful trigger codes, but cannot make it work.
Could you share the code you used for this?
Thanks a lot!!!
I found a wonderful resource that was able to help me with this. Here is the code I'm using:
trigger UpdateOHObject_Trigger on Lead (after update) {
Map<Id, Lead> leadMap = new Map<Id,Lead>();
Lead parent;
for (Integer i = 0; i < Trigger.new.size(); i++){
if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false) {
leadMap.put( Trigger.new[i].Id, Trigger.new[i]);
}
}
if( leadMap.size() > 0 ) {
Set<Id> leadIds = leadMap.keySet();
List<Opportunity_Headings__c> allChildren =
[select Id, Opportunity__c, Account__c, Lead__c from Opportunity_Headings__c where lead__c in :leadIds];
System.debug(allChildren);
for ( Opportunity_Headings__c child : allChildren ) {
if ( leadMap.containsKey( child.Lead__c ) ) {
// lookup the parent lead
parent = leadMap.get( child.Lead__c );
// update the fields on the child object
child.opportunity__c = parent.ConvertedOpportunityId;
child.account__c = parent.ConvertedAccountId;
}
}
System.debug(allChildren);
//try {
update allChildren;
// } catch( Exception e ) {
// could put something here to notify on error
// otherwise it fails silently
// }
}
}
Thanks again Robert!!