Answers.Body: <p>I avoid creating custom php over-rides as it will need checks/updates when Civi is upgraded. I added the same thing using the extension. Below is an example how I achieved</p>
  <pre><code>function extensionname_civicrm_alterReportVar($varType, &amp;$var, &amp;$object) {
    if ('columns' == $varType &amp;&amp; get_class($object) == 'CRM_Report_Form_Activity') {
      $permCustomGroupIds = [];
      $_customGroupExtends = $object-&gt;getVar('_customGroupExtends');
      $_customGroupExtends = array_merge($_customGroupExtends, [
        'Contact',
        'Individual',
        'Household',
        'Organization',
        'Case',
      ]);
  
      if (!CRM_Core_Permission::check('access all custom data')) {
        $allGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
        $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL);
        // do not allow custom data for reports if user doesn't have
        // permission to access custom data.
        if (!empty($this-&gt;_customGroupExtends) &amp;&amp; empty($permCustomGroupIds)) {
          $_customGroupExtends = [];
        }
      }
      $object-&gt;setVar('_customGroupExtends', $_customGroupExtends);
      $object-&gt;addCustomDataToColumns(TRUE, $permCustomGroupIds);
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-30T14:44:10.377Z
Answers.LastActivityDate: 2023-01-30T14:44:10.377Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>Yes <code>_customGroupExtends</code> will still work. You probably want to sync any changes in CRM/Report/Form/Activity.php from the last 4 years into your custom file. But there's an argument that the time would be better spent making a new searchkit search that replaces what the custom report does, but it's true not all civireport features are available yet in searchkit.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-30T05:44:23.777Z
Answers.LastActivityDate: 2023-01-30T05:44:23.777Z
Answers.UserDisplayName: Demerit
Body: <p>Awhile back, I have made a copy of the the CRM/Report/Form/Activity.php, placed it under custom_php and added additional custom Contact and Case fields to the report by updating</p>
  <pre><code>protected $_customGroupExtends = [    'Activity' ];
  </code></pre>
  <p>to</p>
  <pre><code>  protected $_customGroupExtends = [
      'Activity',
      'Contact',
      'Case',
    ];
  </code></pre>
  <p>I know this <a href="https://civicrm.stackexchange.com/questions/24456/how-do-you-display-custom-contact-fields-in-membership-reports">question</a> indicates this was the proper way 4 years ago. I am wondering whether this is still the proper way to show Contact and Case custom fields on Activity report with the current version of CiviCRM 5.57.2?</p>
  
Tags: <custom-fields><civireport><custom-reports>
Title: How to add Contact and Case custom fields to an Activity report?
ThreadText: # How to add Contact and Case custom fields to an Activity report?
  
  (Asked by: username_0 on 2023-01-30)
  
  Awhile back, I have made a copy of the the CRM/Report/Form/Activity.php, placed it under custom\_php and added additional custom Contact and Case fields to the report by updating
  
  ```
  protected $_customGroupExtends = [    'Activity' ];
  
  ```
  
  to
  
  ```
    protected $_customGroupExtends = [
      'Activity',
      'Contact',
      'Case',
    ];
  
  ```
  
  I know this [question](https://civicrm.stackexchange.com/questions/24456/how-do-you-display-custom-contact-fields-in-membership-reports) indicates this was the proper way 4 years ago. I am wondering whether this is still the proper way to show Contact and Case custom fields on Activity report with the current version of CiviCRM 5.57.2?
  
  **Tags:** custom-fields, civireport, custom-reports
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-01-30. Score: 0
  
  I avoid creating custom php over-rides as it will need checks/updates when Civi is upgraded. I added the same thing using the extension. Below is an example how I achieved
  
  ```
  function extensionname_civicrm_alterReportVar($varType, &$var, &$object) {
    if ('columns' == $varType && get_class($object) == 'CRM_Report_Form_Activity') {
      $permCustomGroupIds = [];
      $_customGroupExtends = $object->getVar('_customGroupExtends');
      $_customGroupExtends = array_merge($_customGroupExtends, [
        'Contact',
        'Individual',
        'Household',
        'Organization',
        'Case',
      ]);
  
      if (!CRM_Core_Permission::check('access all custom data')) {
        $allGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
        $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL);
        // do not allow custom data for reports if user doesn't have
        // permission to access custom data.
        if (!empty($this->_customGroupExtends) && empty($permCustomGroupIds)) {
          $_customGroupExtends = [];
        }
      }
      $object->setVar('_customGroupExtends', $_customGroupExtends);
      $object->addCustomDataToColumns(TRUE, $permCustomGroupIds);
    }
  }
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2023-01-30. Score: 0
  
  Yes `_customGroupExtends` will still work. You probably want to sync any changes in CRM/Report/Form/Activity.php from the last 4 years into your custom file. But there's an argument that the time would be better spent making a new searchkit search that replaces what the custom report does, but it's true not all civireport features are available yet in searchkit.
  
  
  ---
  
  