开发者

Salesforce: Moving custom object with data to contact after lead to contact conversion?

开发者 https://www.devze.com 2023-04-04 20:01 出处:网络
I have some leads which have a custom browsing activity object which stores the links they browse through. When I convert a lead to a contact, everything except the custom object gets transferred over

I have some leads which have a custom browsing activity object which stores the links they browse through. When I convert a lead to a contact, everything except the custom object gets transferred over. Is there a way to import that custom object with the data after conversion either through triggers or c# code?

Any help would be appreciated. Thanks


Thank you for your response. This is what I have so far. I am unable to get the browsing data; it only gets the ID related to that activity. I am getting the Id and browsing data which is the Browsing_History__c from the Lead.

Do I need to create a new object to hold it and then insert?

trigger ConvertLead on Lead (after update) 
{
if (Trigger.new.size() == 1)
{
    if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true)
    {
        // if a new contact was created
        if (Trigger.new[0].ConvertedContactId != null) 
        {

            for(Web_Browsing__c wb_old : [Select Id, Browsing_History__c from Web_Browsing__c where Lead__c= :Trigger.new[0].id])
            {

                Web_Browsing__c wb = new Web_Browsing__c(); 
                wb.Contact__c = Trigger.new[0]开发者_运维技巧.ConvertedContactId;
                //Get browsing data

                insert wb;
            }
        }

    }
}

}


There definitely is, but I'm not sure why you would take the C# path on this one. You can avoid the Force.com/REST API since Apex triggers are perfectly capable here.

So in a Lead after update trigger, making sure your trigger.new.IsConverted == true && trigger.old.IsConverted == false (showing this to be a fresh conversion), add those lead objects to a post-processing list.

Then use SOQL on those related custom object Ids to either update or transfer your data.

Also, if you're new to Apex I'd search the Apex dev guide for Bulkify to save some trigger-headaches.

Cheers, Adam


Yes, this is possible using Process Builder or Apex Triggers.

I have step by step instructions and screen shots on my blog: https://douglascayers.wordpress.com/2016/05/29/salesforce-preserve-related-lists-and-chatter-on-lead-conversion/. I've recapped the gist of the idea below.

  1. On the custom object that serves as the related list on the Lead, add another custom lookup field to Account, Contact, and/or Opportunity. (We will populate one or more of these fields from the lead's ConvertedAccountId, ConvertedContactId, or ConvertedOpportunityId fields upon conversion).

    Salesforce: Moving custom object with data to contact after lead to contact conversion?

  2. If using Process Builder, create a process that runs when lead is created or edited.

    Salesforce: Moving custom object with data to contact after lead to contact conversion?

  3. The criteria step should check that the IsConverted field became TRUE.

    Salesforce: Moving custom object with data to contact after lead to contact conversion?

  4. Now add actions to Update Records and choose the related list you want to bring over to the converted account, contact, and/or opportunity. Assign the lead's ConvertedAccountId, ConvertedContactId, or ConvertedOpportunityId field to the respective custom lookup field on your object.

    Salesforce: Moving custom object with data to contact after lead to contact conversion?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号