Records appear multiple times (duplicated) in listview

Hi,
As you can see in the image multiple records that are exactly the same appear in the listview. In the database they appear only once. This only happens with the records that have a value in the two relationship fields.

I read in another post that i will link down below that if you have custom relationship which replicates other existing relationship this can happen and that is normal behaviour, which i think is exactly my case because my two relationship fields are the same and the problem only appears when the two relationships fields have a value. I need the two fields and i can’t delete any of the two.

The other thing is the number of times they repeat. In the image the record is repeated 5 times, that number can vary.

Thanks in advance,

Link to the post i mention.

What is your scenario that you need to pull value from the same relationship twice? Can you not create Relate Fields?

Don’t forget Admin / Repair / Repair Relationships, it might help

The module you see in the image is a custom “Budget” module.
A budget relates to the module “Plants” with the Relate fields. The Relate Fields relates to two differents plants. One always have a value and the other not always. So when i go to a plant in SuiteCRM i have two lists of budgets, one for each relationship(in this list there aren’t any duplicates).

Yes, i tried that and the issue persists.

One thing I’d like to add is that im pulling all this data from a another database using NodeRed.
When i first pull the data for the first time there are no duplicates. The problem appears when i synchronize the suitecrm database with mine.
Then when someone adds a new budget i do an insert to the suitecrm database and only one record is inserted but when this budgets relates to two differents plants and i have to insert to the two relationship tables then the problem appears,
As i mentioned before there’s only duplicates when i insert to the two relationship tables. One is ok.

Hi, when budget has a many-to-many relationship to plants, then you will see duplicates (or triplets …) in your search result as for each plant the budget is associated to.

When you remove the field “plant” from the listview, either with the “Column Chooser” or with studio, you will no longer have duplicates.

Hi, I don’t use any many-to-many relationship. I use two many-to-one relationships (many budgets, one plant).
But putting one of the relate fields to occult with the studio does solve the issue.
Thank you very much.

Hi, I have a many-to-many relationship between Accounts and Contacts. There are duplicate records in Contacts listview. I tried your solution. I removed the field account_name from the Contacts listview and rebuilt relationships. But it didn’t work. The Contacts listview still shows duplicate records. Does anyone have any ideas? Thanks!

SuiteCRM version is 7.11.18.

Hi @Snowl,

Can you add a screenshot of your Contacts listview?

@Snowl

It isn’t duplicate records. The module “Contact” show a few records because the record has several link to accounts. You can see equal links (id) for different records in listview.

@jansiero Sure. Please see the uploaded screenshot. I don’t have Accounts defined in the ListView, EditView, or DetailView. Let me know if you need other information. Thank you @jansiero!

@p.konetskiy Please see the previous discussion in this thread. I know it isn’t “duplicate” records in SuiteCRM’s definition. But I am looking for a solution to show Contacts records as they are in the database. I don’t have Account column defined on the Contacts’ listview, it is confusing to see multiple “same” records. Any ideas would be appreciated. Thanks.

@Snowl
You create the file custom/modules/Contacts/metadata/listviewdefs.php without some lines.
There is the part of the original file modules/Contacts/metadata/listviewdefs.php with comments.

...
$listViewDefs['Contacts'] = array(
    'NAME' => array(
        'width' => '20%',
        'label' => 'LBL_LIST_NAME',
        'link' => true,
        'contextMenu' => array('objectType' => 'sugarPerson',
                               'metaData' => array('contact_id' => '{$ID}',
                                                   'module' => 'Contacts',
                                                   'return_action' => 'ListView',
                                                   'contact_name' => '{$FULL_NAME}',
                                                   'parent_id' => '{$ACCOUNT_ID}',
                                                   'parent_name' => '{$ACCOUNT_NAME}',
                                                   'return_module' => 'Contacts',
                                                   'return_action' => 'ListView',
                                                   'parent_type' => 'Account',
                                                   'notes_parent_type' => 'Account')
                              ),
        'orderBy' => 'name',
        'default' => true,
        'related_fields' => array('first_name', 'last_name', 'salutation'/* remove the values *//*, 'account_name', 'account_id' */),
        ),
    'TITLE' => array(
        'width' => '15%',
        'label' => 'LBL_LIST_TITLE',
        'default' => true),
/* remove the array */
/*    'ACCOUNT_NAME' => array(
        'width' => '34%',
        'label' => 'LBL_LIST_ACCOUNT_NAME',
        'module' => 'Accounts',
        'id' => 'ACCOUNT_ID',
        'link' => true,
        'contextMenu' => array('objectType' => 'sugarAccount',
                               'metaData' => array('return_module' => 'Contacts',
                                                   'return_action' => 'ListView',
                                                   'module' => 'Accounts',
                                                   'return_action' => 'ListView',
                                                   'parent_id' => '{$ACCOUNT_ID}',
                                                   'parent_name' => '{$ACCOUNT_NAME}',
                                                   'account_id' => '{$ACCOUNT_ID}',
                                                   'account_name' => '{$ACCOUNT_NAME}'),
                              ),
        'default' => true,
        'sortable'=> true,
        'ACLTag' => 'ACCOUNT',
        'related_fields' => array('account_id')), */
    'EMAIL1' => array(
        'width' => '15%',
        'label' => 'LBL_LIST_EMAIL_ADDRESS',
        'sortable' => false,
        'link' => true,
        'customCode' => '{$EMAIL1_LINK}',
        'default' => true
        ),
...

Hi, this is not sufficient.

The listviewdefs contains a contextmenu which also includes references to the linked account module. This causes the duplicate search results even when the account_name field is removed from the listviewdefs.

To resolve this:

Edit
custom/modules/Contacts/metadata/listviewdefs.php

In case this file doesn’t exist, create it by:

  • Open Admin / Studio
  • Navigate to Contacts / Layouts / List View
  • Move the field “Account Name” in “Default” to either “Available” or "Hidden
  • Click “Save & Deploy”

In the following entry

  array (
    'width' => '20%',
    'label' => 'LBL_LIST_NAME',

you will find further below:

    'related_fields' =>
    array (
      0 => 'first_name',
      1 => 'last_name',
      2 => 'salutation',
      3 => 'account_name',
      4 => 'account_id',
    ),

Comment out “account_name” and “account_id”:

    'related_fields' =>
    array (
      0 => 'first_name',
      1 => 'last_name',
      2 => 'salutation',
//      3 => 'account_name',
//      4 => 'account_id',
    ),

and save.

Now contacts related to multiple accounts will display only once.

1 Like

Sorry, @p.konetski, I oversaw that you also removed the related fields in your edit.

This works. I commented out “account_name” and “account_id, then Contact records related to multiple accounts display only once.

Thank you so much for your help @jansiero!

Thank you for the help @p.konetskiy!