AnsweredAssumed Answered

Custom SugarWidget no longer showing in subpanel after Update from 6.4.x to 6.5.16 CE

Question asked by aqua.alex aqua.alex on May 23, 2014
Latest reply on Jun 4, 2014 by aqua.alex aqua.alex
Hello, I'm relatively new to SugarCRM and now I ran into a problem I can't find a solution for.

Currently we have a custom module that shows additional details between the relation of Accounts and Contacts. For example his responsibilities in that organization. The custom Button is defined under

 /custom/modules/Accounts/metadata/subpanels/ForContacts.php

'view_rel_button' => array(
  'vname' => 'LBL_LIST_NAME', 
  'widget_class' => 'SubPanelDisplayDetailsLinkAccountsContactsRel', 
  'module' => 'Contacts',
  'width' => '15%',
),
There is also a custom Edit button that is not showing, which is probably due to the same error. On our live system it shows the link to the relation. If I copy that link into my browser it'll also work in 6.5, so it's not the module that is broken, just the subpanel.

Here is the code for the Widget-Field/Button:

/custom/include/generic/SugarWidgets/SugarWidgetAccountContactRelField.php

if(!class_exists('SugarWidgetField'))
  require('include/generic/SugarWidgets/SugarWidgetField.php');
if(!class_exists('ICC_AccountsContactsRel'))
    require('modules/ICC_AccountsContactsRel/ICC_AccountsContactsRel.php');
class SugarWidgetAccountContactRelField extends SugarWidgetField{
    protected $account_id;
    protected $contact_id;
    /**
     * @var ICC_AccountsContactsRel
     */
    protected $account_contact_relation;
       
    public function displayList(&$layout_def)
    {
        $this->account_id = '';
        $this->contact_id = '';       
        if ($_REQUEST['module'] == 'Accounts') {
            $this->contact_id = $layout_def['fields']['ID'];
            $this->account_id = isset($_REQUEST['record']) ? $_REQUEST['record'] : null;
        } else if ($_REQUEST['module'] == 'Contacts') {
            $this->account_id = $layout_def['fields']['ID'];
            $this->contact_id = isset($_REQUEST['record']) ? $_REQUEST['record'] : null;
        }
        if (empty($this->account_id) || empty($this->contact_id)) {
            $this->account_contact_relation = null;
        } else {
            $this->account_contact_relation = new ICC_AccountsContactsRel();
            $this->account_contact_relation->retrieve_by_string_fields(
                array( 'contact_id' => $this->contact_id, 'account_id' => $this->account_id ) );
        }
        return '';
    }
}
/custom/include/generic/SugarWidgets/SugarWidgetSubPanelDisplayDetailsLinkAccountsContactsRel.php

if (!class_exists('SugarWidgetAccountContactRelField'))
  require('custom/include/generic/SugarWidgets/SugarWidgetAccountContactRelField.php');
class SugarWidgetSubPanelDisplayDetailsLinkAccountsContactsRel extends SugarWidgetAccountContactRelField {

    function displayList(&$layout_def) {
        parent::displayList($layout_def);
        global $app_strings;

        $text = '';
        if ($_REQUEST['module'] == 'Accounts') {
            $contact = new Contact();
            $contact->retrieve($this->contact_id);
            $text = $contact->full_name;
        } else if ($_REQUEST['module'] == 'Contacts') {
            $account = new Account();
            $account->retrieve($this->account_id);
            $text = $account->name;
        }
       
        if (empty($this->account_contact_relation)) {
            return '';
        } else {
            $icon_html = SugarThemeRegistry::current()->getImage('view_inline', 'align="absmiddle" border="0"');
            $id = $this->account_contact_relation->id;
            return "<a href='#' "
            . " onMouseOver=\"javascript:subp_nav('ICC_AccountsContactsRel', '" . $id . "', 'd', this"
            . (empty($layout_def['linked_field']) ? "" : ", '{$layout_def['linked_field']}'") . ");\""
            . "     onFocus=\"javascript:subp_nav('ICC_AccountsContactsRel', '" . $id . "', 'd', this"
            . (empty($layout_def['linked_field']) ? "" : ", '{$layout_def['linked_field']}'") . ");\""
            . ' class="listViewTdToolsS1">'
            . $icon_html . ' ' . $text
            . '</a>'
            . ' ';
        }
    }
}   
Any suggestion on why this problem is occurring or what I else I should check would be welcomed.

Thanks,
Alex

Outcomes