No emails shown in subpanel Contact for Accounts

Hi,
I have found this about this issue : Contact Email Address not showing in Subpanels · Issue #168 · salesagility/SuiteCRM-Core · GitHub

This is a major issue in V8 as users cant click on emails in the list and have to open every contact to check if there is an email !

Any information to solve this ?

Thanks for your answers :slight_smile:
Xavier

There’s a workaround here. Enable sorting on the email, then click on column to sort it, and the emails appear.

Thanks Chris,
How Can I “enable sorting” on email ?

Thanks :slight_smile:
Xavier

Here is a step by step on how to enable the sorting, in your case, on the email in the subpanel.

Hi Chris :slight_smile:

I check the page you gave me : this is an explanation to show or hide fields in subpanels, but I dont see how to order the field itself.
To be sure, I have change the order of the field in the table (to put email on the first colum) but it does not change anything…

What did I miss ?
Thanks :slight_smile:
Xavier

@azzy9 Could you explain your workaround for this issue, how exactly did you “enable the sort by option for the emails and then sort by the email in the sub-panel” in version 8.x ?

Hi Chris,
Uh… I dont want to “sort”, I want to see the emails ! You told me to activate the “sort option” but I dont see any option to enable this sorting in the studio.

The only goal is to be able to see the email in the subpanel Contacts in the module Accounts.

Thanks for your help :slight_smile:
Xavier

Hi, I didn’t mean for it as a work around, but to point out that it was a relationship issue in the query, as by sorting it forces it to include the email table into the query.

But for the answer:
go to the sub-panel metadata you want e.g. /legacy/custom/modules/Contacts/metadata/subpanels/Account_subpanel_contacts.php and then add 'sortable' => true,

like:

  'email1' => 
  array (
    'name' => 'email1',
    'vname' => 'LBL_LIST_EMAIL',
    'widget_class' => 'SubPanelEmailLink',
    'width' => '30%',
    'sortable' => true,
    'default' => true,
  ),
1 Like

I just had a quick look, and came up with a very quick dirty way to sort it. use at your own risk.

got to line #932 in /public/legacy/data/SugarBean.php

after

                // Find related email address for sub panel ordering
                if ($order_by && isset($subpanel_def->panel_definition['list_fields'][$order_by]['widget_class']) &&
                    $subpanel_def->panel_definition['list_fields'][$order_by]['widget_class'] === 'SubPanelEmailLink' &&
                    !array_key_exists($order_by, $subquery['query_fields'])) {
                    $relatedBeanTable = $subpanel_def->table_name;
                    $relatedBeanModule = $subpanel_def->get_module_name();
                    $subquery['select'] .= ",
                    (SELECT email_addresses.email_address
                     FROM email_addr_bean_rel
                     JOIN email_addresses ON email_addresses.id = email_addr_bean_rel.email_address_id
                     WHERE
                        email_addr_bean_rel.primary_address = 1 AND
                        email_addr_bean_rel.deleted = 0 AND
                        email_addr_bean_rel.bean_id = $relatedBeanTable.id AND
                        email_addr_bean_rel.bean_module = '$relatedBeanModule') as $order_by";
                }

add:

                // changed to fix https://github.com/salesagility/SuiteCRM-Core/issues/168#issuecomment-1309063873
                elseif (isset($subpanel_def->panel_definition['list_fields']['email1']['widget_class']) &&
                    $subpanel_def->panel_definition['list_fields']['email1']['widget_class'] === 'SubPanelEmailLink' &&
                    !array_key_exists('email1', $subquery['query_fields'])) {
                    $relatedBeanTable = $subpanel_def->table_name;
                    $relatedBeanModule = $subpanel_def->get_module_name();
                    $subquery['select'] .= ",
                    (SELECT email_addresses.email_address
                    FROM email_addr_bean_rel
                    JOIN email_addresses ON email_addresses.id = email_addr_bean_rel.email_address_id
                    WHERE
                        email_addr_bean_rel.primary_address = 1 AND
                        email_addr_bean_rel.deleted = 0 AND
                        email_addr_bean_rel.bean_id = $relatedBeanTable.id AND
                        email_addr_bean_rel.bean_module = '$relatedBeanModule') as email1";
                }

I haven’t seen anything wrong yet and with the conditions shouldn’t cause any problems, but again use at your own risk

1 Like

Thanks :slight_smile:

As the CRM is active, I will not make change “on my own risk” on it :wink:
I will try on a dev one to be sure of the result first.

Thanks for your help :slight_smile:
Xavier

1 Like

Any good result trying on the dev CRM v8?
Is it consistently showing emails in Email column in subpanel Contacts for Accounts module?

I made a Pull Request to fix this bug, thanks @azzy9

1 Like

Thanks to all of you for this :slight_smile:

And… happy new yar 2024 to everyone !!!

Xavier

4 Likes