Lead Conversion, copy newly created Account to custom module

I have a custom module in Lead Conversion which is related to the Accounts module.

When a new Account is created during the Lead conversion the Account is not copied over, however, this works for an Opportunity created during the conversion.

I have followed the "template" in the convert-main layout for Opportunities to attempt to map the Account for the custom moduel but it's not working in 7.8.2 or 7.9.2

in custom/custom/modules/Leads/clients/base/layouts/convert-main/convert-main.php

            array (
              'module' => 'pgopp_PartnershipOpportunities',
              'required' => false,
              'copyData' => true,
              'duplicateCheckOnStart' => true,
              'fieldMapping' =>
              array (
                'affiliation' => 'affiliation_c',
              ),
              'dependentModules' =>
              array (
                'Accounts' =>
                array (
                  'fieldMapping' =>
                  array (
                    'accounts_pgopp_partnershipopportunities_1accounts_ida' => 'id',
                  ),
                ),
              ),
              'hiddenFields' =>
              array (
                'accounts_pgopp_partnershipopportunities_1_name' => 'Accounts',
              ),
            ),
          ),

The names used in the field mapping are from the definition of the relationship between Accounts and the custom module. From the pgopp_PartnershipOpportunities vardefs:

    'accounts_pgopp_partnershipopportunities_1' =>
    array (
      'name' => 'accounts_pgopp_partnershipopportunities_1',
      'type' => 'link',
      'relationship' => 'accounts_pgopp_partnershipopportunities_1',
      'source' => 'non-db',
      'module' => 'Accounts',
      'bean_name' => 'Account',
      'side' => 'right',
      'vname' => 'LBL_ACCOUNTS_PGOPP_PARTNERSHIPOPPORTUNITIES_1_FROM_PGOPP_PARTNERSHIPOPPORTUNITIES_TITLE',
      'id_name' => 'accounts_pgopp_partnershipopportunities_1accounts_ida',
      'link-type' => 'one',
    ),
    'accounts_pgopp_partnershipopportunities_1_name' =>
    array (
      'name' => 'accounts_pgopp_partnershipopportunities_1_name',
      'type' => 'relate',
      'source' => 'non-db',
      'vname' => 'LBL_ACCOUNTS_PGOPP_PARTNERSHIPOPPORTUNITIES_1_FROM_ACCOUNTS_TITLE',
      'save' => true,
      'id_name' => 'accounts_pgopp_partnershipopportunities_1accounts_ida',
      'link' => 'accounts_pgopp_partnershipopportunities_1',
      'table' => 'accounts',
      'module' => 'Accounts',
      'rname' => 'name',
    ),
    'accounts_pgopp_partnershipopportunities_1accounts_ida' =>
    array (
      'name' => 'accounts_pgopp_partnershipopportunities_1accounts_ida',
      'type' => 'id',
      'source' => 'non-db',
      'vname' => 'LBL_ACCOUNTS_PGOPP_PARTNERSHIPOPPORTUNITIES_1_FROM_PGOPP_PARTNERSHIPOPPORTUNITIES_TITLE_ID',
      'id_name' => 'accounts_pgopp_partnershipopportunities_1accounts_ida',
      'link' => 'accounts_pgopp_partnershipopportunities_1',
      'table' => 'accounts',
      'module' => 'Accounts',
      'rname' => 'id',
      'reportable' => false,
      'side' => 'right',
      'massupdate' => false,
      'duplicate_merge' => 'disabled',
      'hideacl' => true,
    ),

The Account is mapped correctly when an existing account is selected but not when a new Account is created in the Lead Conversion process.

Any thoughts on what I'm doing wrong?

thanks,
FrancescaS

Parents
  • Hi Francesca Shiekh,

    This works for opportunity created during Conversion because for opportunity, the logic is hard coded in the core file modules/Leads/LeadConvert.php in the function updateOpportunityWithAccountInformation, which populates the account_id into the opportunity bean.
    However, this will not work for your Custom module as there is no logic at the back end to relate account with this custom module. So you need to extend this class i.e LeadConvert to include your logic for custom module, and then you need to override LeadConvertApi and inside the method convertLead, instead of creating object of LeadConvert class you can create object of your custom class which you extended from LeadConvert class.

    Kind Regards,

    Rolustech Support

    Email: support@rolustech.com

    Website: www.rolustech.com

Reply
  • Hi Francesca Shiekh,

    This works for opportunity created during Conversion because for opportunity, the logic is hard coded in the core file modules/Leads/LeadConvert.php in the function updateOpportunityWithAccountInformation, which populates the account_id into the opportunity bean.
    However, this will not work for your Custom module as there is no logic at the back end to relate account with this custom module. So you need to extend this class i.e LeadConvert to include your logic for custom module, and then you need to override LeadConvertApi and inside the method convertLead, instead of creating object of LeadConvert class you can create object of your custom class which you extended from LeadConvert class.

    Kind Regards,

    Rolustech Support

    Email: support@rolustech.com

    Website: www.rolustech.com

Children
No Data