I've only started trying to change some features of an existing CiviCRM database in a testsystem (using CiviCases). So I am still a beginner, I excuse myself if this is a silly question, and any hint will be appreciated :)

I want to include a feature that will exclude all the activities with the grouping value "system" from the case view. Right now, the case view is spammed with activities not relevant to the users (for example, "Case type changed from ... to ..."). The activities are given this grouping value in a table called civicrm_option_value.

So I suppose I have to include some filter into the file /civicrm/CRM/Case/Form/CaseView.php, accessing each activity's grouping and testing it for "system". Can you give me any hint how I can access the activities' grouping value?

Thanks in advance, emma

  • a non-dev CMS dependent option might be to achieve this part of your workflow via Drupal Views
    – petednz - fuzion
    Commented Aug 24, 2020 at 21:01

3 Answers 3


The function that is responsible to build the list of activities on case is CRM_Case_BAO_Case::getCaseActivity(). It is very difficult to alter the function via custom module/plugin/extension.

I would create an extension that would alter the page callback for 'civicrm/ajax/activity' to custom function (eg CRM_ExtName_Page_AJAX::getCaseActivity using hook_civicrm_alterMenu hook. Copy CRM_Activity_Page_AJAX::getCaseActivity() into your custom php file i.e CRM_ExtName_Page_AJAX::getCaseActivity() and change the line below line to your custom function which will basically copy paste of CRM_Case_BAO_Case::getCaseActivity function with change the where clause to include your conditions

$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);



  • Thank you, I will work myself into that!
    – emma
    Commented Aug 25, 2020 at 12:33
  • I don't quite understand the "change the where clause to include your conditions" part, as the CRM_Activity_Page_AJAX::getCaseActivity() does not have a where clause. Can you tell me what exactly you mean by that?
    – emma
    Commented Aug 25, 2020 at 13:42
  • I mean something like creating class gist.github.com/pradpnayak/c3152131f857ce2e80fcf79fa4df22be and changing the where clause in getCaseActivity() as per your needs Commented Aug 25, 2020 at 14:09

In the end, I directly changed the CRM_Case_BAO_Case::getCaseActivity function instead of creating an extension.

Specifically, I changed this function's $where variable to:

    $where = "
            WHERE cca.case_id= %1
              AND ca.is_current_revision = 1
              AND cov.grouping = 'visible'";

Here, "cov" is the alias for the table civicrm_option_value. The alias is already predefined in the $from variable above.

I added the grouping value "visible" manually in the database to those activities that should be visible in the case view.

  • so long as you have a good solid process for managing this during upgrades. i might get one of our folk to extensionize this if they and some users deem it useful - thanks for sharing
    – petednz - fuzion
    Commented Sep 17, 2020 at 3:12

I've posted almost exactly the same question and got some pretty helpful answers.

Especially the extension mentioned here seems to be really useful (I have not tried it yet, though).

  • Thank you! I'd prefer not to include the official new CiviCase extension, because I only want to change this very specific issue, and the rest should stay as it is. I may create a small extension only for this purpose myself.
    – emma
    Commented Aug 26, 2020 at 9:20

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.