Duplicate Check on clicking associate button on 'Leads to Account Conversion Panel'

Hi All

           I want the duplicate check to be performed when the user clicks the associate button in the leads to accounts conversion panel.

/<>/modules/Leads/clients/base/layouts/convert-panel/convert-panel.js

          I have been working around this file but dint seem to progress.

Regard

Sidhu Tevfik Tümer

  • Hi sidhu,

    There is already a duplication check out of box when you are creating an account while converting a Lead.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • Hi Tevfik Tümer

             The duplicate check is happening during rendering the panels during lead conversion.But not on clicking the associate button.

    Regards

    Sidhu

  • Hi Tevfik Tümer

                    I have gone through /<>/modules/Leads/clients/base/layouts/convert-panel/convert-panel.js

    and found out that the onclicking the associate button it is going to this function handleAssociateClick.

    It is in this function that i want to do the duplicate check.

    convertPanelEvents['click [name="associate_button"]'] = 'handleAssociateClick';

    handleAssociateClick: function(event) {

            if (!$(event.currentTarget).hasClass('disabled')) {

                if (this.currentToggle === this.TOGGLE_CREATE) {

                    this.runCreateValidation();

                } else {

                    this.markPanelComplete(this.duplicateView.context.get('selection_model'));

                }

            }

            event.stopPropagation();

        },

  • Hi sidhu,

    I've tried to understand your approach but couldn't get it. So, If i answer your question regardlessly your use case,

    you need to duplicate modules/Leads/clients/base/layouts/convert-panel/convert-panel.js to custom folder like; custom/modules/Leads/clients/base/layouts/convert-panel/convert-panel.js

    and modify handleAssociateClick function like you said.

    If you wanna make a duplication check all you need to do call;

    this.renderDupeCheckList()
    

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • Hi Tevfik Tümer

                      I have tried this but it dint work out.

    I worked around the below code and it rendered already existing duplicate check that comes on rendering the panels during lead conversion

    handleAssociateClick: function(event) {

      this.dupecheckList = app.view.createLayout({

                    context: this.duplicateView.context,// i need this to happen for the new account i am creating

                    name: 'create-dupecheck',

                    module: "Accounts"

                });

                this.addComponent(this.dupecheckList);

  • Hi sidhu sidhu

    Duplicate Check logic can be added/modified for a module in the vardef.  The following is an example for Contacts:

    'duplicate_check' => array(
        'enabled' => true,
        'FilterDuplicateCheck' => array(
            'filter_template' => array(
                array(
                    '$and' => array(
                        array('first_name' => array('$starts' => '$first_name')),
                        array('last_name' => array('$starts' => '$last_name')),
                        array('accounts.id' => array('$equals' => '$account_id')),
                        array('dnb_principal_id' => array('$equals' => '$dnb_principal_id')),
                    )
                ),
            ),
            'ranking_fields' => array(
            ),
        ),
    )

    The logic is based on the FilterApi syntax. For convert lead, the option to turn on/off duplicate check needs to be implemented through modifying the convert-main.php.  For your custom module, you can modify the following attribute:

    'duplicateCheckOnStart' => true,

    to decide whether duplicate check runs when you start the lead conversion process.

    Regards

    John

  • Hi sidhu sidhu

    For Duplicate Check on Conversion Lead to do is

    All we need to do is in custom/modules/Leads/clients/base/layouts/convert-panel/convert-panel.js ( if file is not there then copy it from modules/Leads/clients/base/layouts/convert-panel/convert-panel.js)

    Under runCreateValidation function inside isValid add following lines

      this.addDupeCheckComponent();

      if(this.triggerDuplicateCheck()){

      console.log("duplicates found");

      }else{

      console.log("no duplicates found");

      this.markPanelComplete(model);

      }

    For Checking additional Validation to do is

    All we need to do is in custom/modules/Leads/clients/base/layouts/convert-panel/convert-panel.js ( if file is not there then copy it from modules/Leads/clients/base/layouts/convert-panel/convert-panel.js)

    Under runCreateValidation function add :

    model.addValidationTask('check_vat_c', _.bind(function(fields, errors, callback) {

    // Write your validation logic here

    // Example for field should not be empty

    if (_.isEmpty(model.get('your-field-name')))

      {

      errors['your-field-name'] = errors['your-field-name'] || {};

      errors['your-field-name'].required = true;

      }

      callback(null, fields, errors);

      }, this));

    Hope this Helps

    Best Regards

    S Ramana Raju

  • Hi Ramana Raju Santhana

                  

    I want the same duplication check functionality to be performed on Account during lead conversion. Can you please provide me the suggestion on how to implement the duplicate check in AssociateClick function.

            I tried with the below code that you have mentioned, but I haven't got any solution. Kindly assist.

       

    Under runCreateValidation function inside isValid if condition I added the following lines

      this.addDupeCheckComponent();

      if(this.triggerDuplicateCheck()){

      console.log("duplicates found");

      }else{

      console.log("no duplicates found");

      this.markPanelComplete(model);

      }