CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Report and Search UI Discussion (Moderators: CiviTeacher.com, TwoMice) »
  • Custom search - cannot get sorting right
Pages: [1]

Author Topic: Custom search - cannot get sorting right  (Read 1199 times)

cray146

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 1
  • CiviCRM version: 4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.3
Custom search - cannot get sorting right
March 12, 2013, 07:31:11 am
Hi,

I created a custom search to create mailing labels. The search works fine but i cannot get the list sorted as i want. The list should be sorted to distribution code and postal code to make post-processing a bit easier.

The result fields are:
  • Contact ID
  • First Name
  • Last Name
  • Street Address
  • Postal Code
  • City
  • Distribution Code (custom field tied to membership)

The sql statement has an order by clause to sort on distribution code and postal code (which works fine when you run it against the database). In the Custom Search result screen however, the records seem to be sorted by contact ID.

Any ideas to get the sorting right?

Thanks

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Custom search - cannot get sorting right
March 12, 2013, 09:04:05 am

Have u implemented the contactIDs function in your custom search and ensure that the contactIDs returned there are in the order you want the mailing labels printed?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

cray146

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 1
  • CiviCRM version: 4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.3
Re: Custom search - cannot get sorting right
March 12, 2013, 12:28:16 pm
Hi Lobo,

The contactIDs function is implemented, it calls the all() function with the justIds flag set.  Running the sql statement that is composed in all() with justIds set separately against the database gives me the ids in the right order. So the queries seem right.

It seems like the sorting option on the columns overrule the default sorting order i defined.  Is there an option to disable sorting through the UI (apart from taking it out the template which i tried to no avail).

Thanks

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Report and Search UI Discussion (Moderators: CiviTeacher.com, TwoMice) »
  • Custom search - cannot get sorting right

This forum was archived on 2017-11-26.