How to set a default sorting order for a subpanel in SugarCRM 7

As in Sugarcrm 6.x we can set the default sorting order of a subpanel by changing the layout defs of the subpanel as explained here:

How to change default sort in custom subpanel - sugarcrm?

But how can i achieve the same sorting functionality in a standard subpanel visible in a sidecar enabled module in SugarCRM 7.6

Actually what i am trying to acheieve is setting a default sort by date_start DESC for a Meetings subpanel visible in Accounts module.

Any ideas how to implement this sorting functionality.

  • Hi Sheikh,

    The way I would do it is to create a custom subpanel-list in the Meetings in custom/modules/Meetings/clients/base/views/subpanel-list/subpanel-list.php

    <?PHP
    
    $viewdefs['Meetings']['base']['view']['subpanel-list'] = array(
      'panels' =>
      array(
        array(
          'name' => 'panel_header',
          'label' => 'LBL_PANEL_1',
          'fields' =>
          array(
            array(
              'name' => 'name',
              'label' => 'LBL_LIST_SUBJECT',
              'enabled' => true,
              'default' => true,
              'link' => true,
            ),
            array(
              'name' => 'status',
              'label' => 'LBL_LIST_STATUS',
              'enabled' => true,
              'default' => true,
            ),
            array(
              'target_record_key' => 'contact_id',
              'target_module' => 'Contacts',
              'name' => 'contact_name',
              'label' => 'LBL_LIST_CONTACT',
              'link' => true,
              'module' => 'Contacts',
              'enabled' => true,
              'default' => true,
              'related_fields' => array('contact_id'),
            ),
            array(
              'name' => 'date_start',
              'label' => 'LBL_LIST_DATE',
              'enabled' => true,
              'default' => true,
            ),
            array(
              'name' => 'date_end',
              'label' => 'LBL_DATE_END',
              'enabled' => true,
              'default' => true,
            ),
            array(
              'name' => 'assigned_user_name',
              'target_record_key' => 'assigned_user_id',
              'target_module' => 'Employees',
              'label' => 'LBL_LIST_ASSIGNED_TO_NAME',
              'enabled' => true,
              'default' => true,
              'sortable' => false,
            ),
          ),
        ),
      ),
      'rowactions' => array(
        'actions' => array(
          array(
              'type' => 'rowaction',
              'name' => 'edit_button',
              'icon' => 'icon-pencil',
              'label' => 'LBL_EDIT_BUTTON',
              'event' => 'list:editrow:fire',
              'acl_action' => 'edit',
              'allow_bwc' => true,
          ),
          array(
            'type' => 'unlink-action',
            'icon' => 'icon-unlink',
            'label' => 'LBL_UNLINK_BUTTON',
          ),
          array(
            'type' => 'closebutton',
            'icon' => 'icon-remove-circle',
            'name' => 'record-close',
            'label' => 'LBL_CLOSE_BUTTON_TITLE',
            'acl_action' => 'edit',
          ),
        ),
      ),
     'orderBy' => 
      array (
        'field' => 'date_start',
        'direction' => 'desc',
      ),
    );
    

    Check from line 84 to 88 is the code that will create the order you want. If you only want it to appear on Accounts you can create the subpanel inside the Accounts module from studio, then go find the view meta that is created it inside Meetings called something like "subpanel-for-accounts-meetings" I'm not sure.

    Hope it helps