Salesforce:在导致联系人转换后将带有数据的自定义对象移动到联系人?

发布于 2024-12-04 04:35:34 字数 950 浏览 0 评论 0原文

我有一些潜在客户有一个自定义浏览活动对象,用于存储他们浏览的链接。当我将潜在客户转换为联系人时,除自定义对象之外的所有内容都会被转移。有没有办法通过触发器或 C# 代码在转换后导入带有数据的自定义对象?

任何帮助将不胜感激。谢谢


您的回复。 这是我到目前为止所拥有的。我无法获取浏览数据;它只获取与该活动相关的 ID。我正在从 Lead 获取 Id 和浏览数据,即 Browsing_History__c。

我是否需要创建一个新对象来保存它然后插入?

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;
            }
        }

    }
}

}

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;
            }
        }

    }
}

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深者入戏 2024-12-11 04:35:34

肯定有,但我不确定为什么你会在这个上采用 C# 路径。您可以避免使用 Force.com/REST API,因为 Apex 触发器在这里完全有能力。

因此,在更新后的潜在客户触发器中,请确保您的trigger.new.IsConverted == true && trigger.old.IsConverted == false(表明这是一个新的转换),将这些主要对象添加到后处理列表中。

然后对这些相关的自定义对象 ID 使用 SOQL 来更新或传输数据。

另外,如果您是 Apex 新手,我会在 Apex 开发指南中搜索 Bulkify,以解决一些令人头疼的问题。

干杯,
亚当

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

柳絮泡泡 2024-12-11 04:35:34

是的,这可以使用 Process Builder 或 Apex 触发器来实现。

我的博客上有分步说明和屏幕截图:https://douglascayers.wordpress.com/2016/05/29/salesforce-preserve-lated-lists-and-chatter-on-lead-conversion/。我在下面回顾了这个想法的要点。

  1. 在充当潜在客户相关列表的自定义对象上,
    将另一个自定义查找字段添加到帐户、联系人和/或
    机会。 (我们将从
    潜在客户的 ConvertedAccountIdConvertedContactId
    转换时的 ConvertedOpportunityId 字段)。
    自定义联系人字段
  2. 如果使用流程生成器,请创建一个在创建或编辑潜在客户时运行的流程。
    引导流程
  3. 标准步骤应检查 IsConverted 字段是否变为 TRUE
    铅是转换后的条件
  4. 现在将操作添加到更新记录,并选择您想要带入转换后的客户、联系人和/或机会的相关列表。将潜在客户的 ConvertedAccountIdConvertedContactIdConvertedOpportunityId 字段分配给对象上相应的自定义查找字段。
    领先更新记录动作

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).
    custom contact field
  2. If using Process Builder, create a process that runs when lead is created or edited.
    lead process
  3. The criteria step should check that the IsConverted field became TRUE.
    lead is converted criteria
  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.
    lead update records action
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文