Body: <p>Using CiviCRM 4.6.4, I am trying to update the activity report to include the custom fields from the contact form.  By using the following code they show up in the list but does not allow sorting on the custom fields.</p>
  
  <pre><code>protected $_customGroupExtends = array(
    'Activity', 'Contact', 'Organization');
  protected $_nonDisplayFields = array();
  public function __construct() {
  
   $this-&gt;_autoIncludeIndexedFieldsAsOrderBys = 1;
  </code></pre>
  
  <p>Here is the error
  DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'value_client_project_definition_3_civireport.corridor..."</p>
  
  <p>If you open the activity report then go to sorting and select one of the displayed custom fields that is added by adding the following code to the report.
  $this->_autoIncludeIndexedFieldsAsOrderBys = 1;</p>
  
  <p>The DB error is generated.</p>
  
  <p>Thanks in advance</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-21T18:59:15.250Z
Comments.Text: This question feels unclear to me. Can you edit your question to give more context about what exactly you changed? Maybe show a diff with the original? Also what version of CiviCRM is this?
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-30T23:24:10.803Z
Comments.Text: this is version 4.6.4  The code added was  'Contact', 'Organization' and $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
Comments.UserDisplayName: user2201570
Tags: <civireport>
Title: Activity Report does not allow grouping by custom fields
ThreadText: # Activity Report does not allow grouping by custom fields
  
  (Asked by: username_0 on 2015-07-21)
  
  Using CiviCRM 4.6.4, I am trying to update the activity report to include the custom fields from the contact form. By using the following code they show up in the list but does not allow sorting on the custom fields.
  
  ```
  protected $_customGroupExtends = array(
    'Activity', 'Contact', 'Organization');
  protected $_nonDisplayFields = array();
  public function __construct() {
  
   $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
  
  ```
  
  Here is the error
  DB\_common->raiseError(-19, NULL, NULL, NULL, "1054 \*\* Unknown column 'value\_client\_project\_definition\_3\_civireport.corridor..."
  
  If you open the activity report then go to sorting and select one of the displayed custom fields that is added by adding the following code to the report.
  $this->\_autoIncludeIndexedFieldsAsOrderBys = 1;
  
  The DB error is generated.
  
  Thanks in advance
  
  **Tags:** civireport
  
  > **Comments:**
  > **username_1**: This question feels unclear to me. Can you edit your question to give more context about what exactly you changed? Maybe show a diff with the original? Also what version of CiviCRM is this?  
  > **username_0**: this is version 4.6.4  The code added was  'Contact', 'Organization' and $this->_autoIncludeIndexedFieldsAsOrderBys = 1;  
  
  ---
  
  ## 0 answers
  
  