Results 1 to 6 of 6

Thread: Leads - Sort name column by last name in Listview

  1. #1
    Gorgar is offline Junior Member
    Join Date
    May 2008
    Posts
    3

    Default Leads - Sort name column by last name in Listview

    Hello,

    maybe this is trivial and I'm too blind to find the right option. I'd like the name column in the listview of leads to be sorted by last_name instead of first_name. My first guess was to change the locale setting and set l first, but it has no effects.

    Also changes in listviewdefs.php turned out unsuccessfull. Maybe someone can give me a hint?

    Many thanks in advance...

  2. #2
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Leads - Sort name column by last name in Listview

    Quote Originally Posted by Gorgar
    Hello,

    maybe this is trivial and I'm too blind to find the right option. I'd like the name column in the listview of leads to be sorted by last_name instead of first_name. My first guess was to change the locale setting and set l first, but it has no effects.

    Also changes in listviewdefs.php turned out unsuccessfull. Maybe someone can give me a hint?

    Many thanks in advance...
    That's because "name" is "first name + last name".
    To sort the listview by last name, go in Admin->Studio->Leads->Layouts->Listview
    and move "last name" to Default column, then save&deploy.
    What do you think the cookie monster eats ?

  3. #3
    Gorgar is offline Junior Member
    Join Date
    May 2008
    Posts
    3

    Default Re: Leads - Sort name column by last name in Listview

    Quote Originally Posted by DragonflyMaster
    That's because "name" is "first name + last name".
    To sort the listview by last name, go in Admin->Studio->Leads->Layouts->Listview
    and move "last name" to Default column, then save&deploy.
    Indeed, but it also includes "salutation" and this is ignored. it seems only to be an issue of changing the sequence of variables or a small change to a sql query. I'm interested in the former, but if a code change is neccessary I would accept that finally.

    I already tried your proposal, added the three types of fields to the listview layout (salutation, first name and last name). But after the removal of Name, no results were shown in the listview. So "Name" is obviously absolute neccessary? And there is no option I can set in the vardefs.php or listviewdefs.php (e.g sort_on or sort_by)?

    Thx

  4. #4
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Leads - Sort name column by last name in Listview

    If you look in your cache folder, you'll find a Leadvardefs.php inside cache/modules/Leads/; in there you'll see this:
    PHP Code:
      'name' => 
          array (
            
    'name' => 'name',
            
    'rname' => 'name',
            
    'vname' => 'LBL_FULL_NAME',
            
    'type' => 'name',
            
    'fields' => 
            array (
              
    => 'first_name',
              
    => 'last_name',
            ),
            
    'sort_on' => 'last_name',
            
    'source' => 'non-db',
            
    'group' => 'last_name',
            
    'len' => '255',
            
    'db_concat_fields' => 
            array (
              
    => 'first_name',
            
    => 'last_name',
            ), 
    Inverting the last two lines makes that field sortable by last name:
    PHP Code:
    => 'last_name',
    => 'first_name'
    CON: this file is inside the cache folder so it is overwritten at any code change.
    What do you think the cookie monster eats ?

  5. #5
    Gorgar is offline Junior Member
    Join Date
    May 2008
    Posts
    3

    Default Re: Leads - Sort name column by last name in Listview

    Many thanks, that was the right hint. For the present it does the job pretty well...

  6. #6
    cgray is offline Junior Member
    Join Date
    Nov 2007
    Posts
    3

    Default Re: Leads - Sort name column by last name in Listview

    If you want to make this upgrade safe, make the change in custom/Extension/modules/Leads/Ext/Vardefs/vardefs.ext.php

    Code:
    <?php
    /*****************************************************************************
    Modify the sort order of Leads name
    currently sorts by first name.
    modify so that it sorts by last name, then first name 
    See: https://www.sugarcrm.com/forums/showthread.php?t=33427
    and: http://a17g.com/?p=20
     ********************************************************************************/
    $dictionary["Lead"]["fields"]["name"]["db_concat_fields"] = array (
    	0 => 'last_name',
    	1 => 'first_name',
          );
    ?>
    Then do a Quick Rebuild and Repair of the Leads module

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Manually drop scheme (5.0 upgrade) ?
    By niallhannon in forum Installation and Upgrade Help
    Replies: 1
    Last Post: 2008-01-07, 05:41 PM
  2. subpanel column sort widgets
    By stevec in forum Developer Help
    Replies: 2
    Last Post: 2007-09-18, 09:02 AM
  3. leads sort order by name
    By sigarffs in forum General Discussion
    Replies: 2
    Last Post: 2007-06-27, 09:35 PM
  4. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  5. SugarCrm 4.0 Patch
    By mgamboa in forum General Discussion
    Replies: 0
    Last Post: 2005-12-21, 04:14 PM

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
  •