Convert Lead to Opportunity - Transfer History

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teetech
    Junior Member
    • Nov 2023
    • 5

    Convert Lead to Opportunity - Transfer History

    Hello,

    I'm fairly new to the CRM and was wondering if someone has an existing module or workflow that would move over history (specifically linked emails) into an opportunity once converted. Often, the lead turns into a single opportunity where we want all history transferred.

    Thanks!
  • Kharg
    Senior Member
    • Jun 2021
    • 440

    #2
    Hi,

    I created an extension to copy the Notes
    Extension to copy Lead stream notes to the converted entity (Account/Contact/Opportunity). - Kharg/copy-lead-notes


    I may consider adding this functionality to duplicate the history to the converted entity depending on the difficulty of the task

    It may be more difficult for emails.

    Comment

    • teetech
      Junior Member
      • Nov 2023
      • 5

      #3
      Hi Kharg,

      Thanks for the reply and for the creation of extension.

      I actually have the extension installed previously but haven't had any luck with it working.

      Is there anything special to get it activated and working? In the extension settings, the "copy to" is checked off already.

      Comment

      • Kharg
        Senior Member
        • Jun 2021
        • 440

        #4
        You have to check it on to enable the extension.

        it will transfer only newly converted records, not for past conversions.

        Comment

        • teetech
          Junior Member
          • Nov 2023
          • 5

          #5
          Thanks.

          Curious to know everyones workflow... from lead to opportunity.

          Many conversations start as lead and then goes to opportunity but history stays with lead.

          What does everyone do?

          Comment

          • victor
            Active Community Member
            • Aug 2022
            • 770

            #6
            teetech,

            Workflow is based on this post: https://forum.espocrm.com/forum/gene...7603#post97603. And if you wish, you can change the Conditions, but this example is about Manual.

            Note that emails can only have one Parent. That is, emails will be in the history of either leads or opportunities from which you converted them.

            You need to create a Workflow with:

            Click image for larger version  Name:	image.png Views:	0 Size:	37.7 KB ID:	101538

            Actions: Execute Formula Script
            Code:
            $leadId = workflow\targetEntity\attribute('id');
            $opportunityId = workflow\targetEntity\attribute('createdOpportunit yId');
            $opportunityName = workflow\targetEntity\attribute('createdOpportunit yName');
            
            $leadsEmailIds = record\findRelatedMany('Lead', $leadId, 'emails', 10000, 'createdAt', 'desc');
            
            $emailsCount = array\length($leadsEmailIds);
            
            $i = 0;
            while ($i < $emailsCount) {
            
            $emailId = array\at($leadsEmailIds, $i);
            record\update('Email', $emailId,
            'parentType', 'Opportunity',
            'parentName', $opportunityName,
            'parentId', $opportunityId);
            
            $i = $i + 1;
            }
            Last edited by victor; 01-12-2024, 02:36 PM.

            Comment

            Working...