I'm trying to display cases in reverse order in contact summary Cases Tab. I tried using hook called civicrm_searchColumns( $objectName, &$headers, &$values, &$selector )

and changed the values using $values = array_reverse($values);. but some contacts got more than 100 cases split into different pages. using this hook I cant get cases in ORDER BY id DESC order.

I checked relevant php file CRM_Case_Page_Tab. Its using controller in browse function like below

  public function browse() {

    $controller = new CRM_Core_Controller_Simple('CRM_Case_Form_Search', ts('Case'), CRM_Core_Action::BROWSE);
    $controller->set('limit', 20);
    $controller->set('force', 1);
    $controller->set('context', 'case');

Can anyone suggest me is there any option to add sort by to this controller object for case id in descending order?

or where to add this order by case id to the actual query?


1 Answer 1


I found quick hack to add sort in CRM_Case_Selector_Search class file. Though its not good practice to touch core, I could not find better option to get around this problem

  public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
       //adding sort here for descending
        $sort->_vars[1] = array('name'=>'case_id',
                                'title'=>ts('Case ID')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.