Results 1 to 3 of 3

Thread: Sorting by Account

  1. #1
    ranthony is offline Member
    Join Date
    Dec 2007
    Posts
    9

    Default Sorting by Account

    I have a custom module with a listview that includes the Account that it is related to. I added a relate field in my custom module, it added a db field account_id as the foreign key and a non-db field account. The problem is the select statement that is generated when trying to sort by the account has "ORDER BY account" in it. That field does not exist in the database, so I get an error 1054 in the debug log when I try to sort by that column by clicking on it. So either you have to run this query against wherever the non-db fields are stored or add a join into the query on the foreign key and then sort by accounts.name. The problem is I have no idea where to modify those things.

    I believe the problem lies in my listviewdefs.php file in \custom\modules\GoTo1_GoToMyPC\metadata\. Here's that file:
    Code:
    $module_name = 'GoTo1_GoToMyPC';
    $listViewDefs = array (
    $module_name =>
    array (
      'ACCOUNT' => 
      array (
        'width' => '20',
        'label' => 'LBL_ACCOUNT',
        'module' => 'Accounts',
        'id' => 'ACCOUNT_ID',
        'link' => true,
        'related_fields' => 
        array (
          0 => 'account_id',
        ),
        'default' => true,
      ),
      'NAME' => 
      array (
        'width' => '15',
        'label' => 'LBL_NAME',
        'default' => true,
        'link' => true,
      ),
      'EMAIL' => 
      array (
        'width' => '15',
        'label' => 'LBL_EMAIL',
        'default' => true,
      ),
      'ACCOUNT_PASS' => 
      array (
        'width' => '10',
        'label' => 'LBL_ACCOUNT_PASS',
        'default' => true,
      ),
      'ACCESS_CODE' => 
      array (
        'width' => '10',
        'label' => 'LBL_ACCESS_CODE',
        'default' => true,
      ),
      'ASSIGNED_USER_NAME' => 
      array (
        'width' => '9',
        'label' => 'LBL_ASSIGNED_TO_NAME',
        'default' => false,
        'module' => 'Users',
        'id' => 'ASSIGNED_USER_ID',
        'link' => true,
        'related_fields' => 
        array (
          0 => 'assigned_user_id',
        ),
      ),
    )
    );
    There are a few different things in, say, the contacts listviewdefs.php and it seems to be able to sort by Account. Anyone know what would make this behave?

    Thanks,
    Ryan

  2. #2
    lion is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: Sorting by Account

    do something like that in your listviewdefs.php:
    PHP Code:
      'ACCOUNT' =>
      array (
        
    'width' => '1',
        
    'label' => 'LBL_SHORT_ACCOUNT',
        
    'default' => true,
        
    'link' => true,
        
    'module' => 'Accounts',
        
    'id' => 'ACCOUNT_ID',
        
    'related_fields' => array('account_id'),
      ), 
    without the related_fields array account_id is not available and therefore account is always empty.

  3. #3
    lion is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: Sorting by Account

    See http://www.sugarcrm.com/forums/showt...d=1#post131564 on how to get search working.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2006-08-28, 01:27 PM
  2. Showing Member Organizations of Account
    By Lennu in forum General Discussion
    Replies: 0
    Last Post: 2006-03-27, 12:31 PM
  3. Import contact on existing account
    By esolarc in forum Developer Help
    Replies: 1
    Last Post: 2006-03-22, 01:21 PM
  4. Automatically Link Lead to Account
    By cmarcus in forum Feature Requests
    Replies: 2
    Last Post: 2006-03-20, 02:44 PM
  5. Replies: 0
    Last Post: 2005-10-18, 11:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •