Answers.Body: <p>In the end, I directly changed the <code>CRM_Case_BAO_Case::getCaseActivity</code> function instead of creating an extension.</p>
  <p>Specifically, I changed this function's <code>$where</code> variable to:</p>
  <pre><code>    $where = &quot;
              WHERE cca.case_id= %1
                AND ca.is_current_revision = 1
                AND cov.grouping = 'visible'&quot;;
  </code></pre>
  <p>Here, &quot;cov&quot; is the alias for the table <code>civicrm_option_value</code>. The alias is already predefined in the <code>$from</code> variable above.</p>
  <p>I added the grouping value &quot;visible&quot; manually in the database to those activities that should be visible in the case view.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-17T03:12:12.613Z
Answers.Text: 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
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-16T10:06:40.047Z
Answers.LastActivityDate: 2020-09-16T10:06:40.047Z
Answers.UserDisplayName: emma
Answers.Body: <p>The function that is responsible to build the list of activities on case is <code>CRM_Case_BAO_Case::getCaseActivity()</code>. It is very difficult to alter the function via custom module/plugin/extension.</p>
  <p>I would create an extension that would alter the page callback for '<code>civicrm/ajax/activity</code>' to custom function (eg <code>CRM_ExtName_Page_AJAX::getCaseActivity</code> using <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMenu/" rel="nofollow noreferrer">hook_civicrm_alterMenu</a> hook. Copy <code>CRM_Activity_Page_AJAX::getCaseActivity()</code> into your custom php file i.e <code>CRM_ExtName_Page_AJAX::getCaseActivity()</code> and change the line below line to your custom function which will basically copy paste of <code>CRM_Case_BAO_Case::getCaseActivity</code> function with change the where clause to include your conditions</p>
  <pre><code>$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
  </code></pre>
  <p>HTH</p>
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-25T12:33:27.163Z
Answers.Text: Thank you, I will work myself into that!
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-25T13:42:11.213Z
Answers.Text: 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?
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-25T14:09:41.977Z
Answers.Text: I mean something like creating class https://gist.github.com/pradpnayak/c3152131f857ce2e80fcf79fa4df22be and changing the where clause in getCaseActivity() as per your needs
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-24T15:15:23.817Z
Answers.LastActivityDate: 2020-08-24T15:15:23.817Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>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 :)</p>
  <p>I want to include a feature that will exclude all the activities with the grouping value &quot;system&quot; from the case view. Right now, the case view is spammed with activities not relevant to the users (for example, &quot;Case type changed from ... to ...&quot;).
  The activities are given this grouping value in a table called civicrm_option_value.</p>
  <p>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 &quot;system&quot;.
  Can you give me any hint how I can access the activities' grouping value?</p>
  <p>Thanks in advance,
  emma</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-24T21:01:29.273Z
Comments.Text: a non-dev CMS dependent option might be to achieve this part of your workflow via Drupal Views
Comments.UserDisplayName: petednz - fuzion
Tags: <civicase><activity>
Title: How can I access an activity's grouping value in CiviCases?
ThreadText: # How can I access an activity's grouping value in CiviCases?
  
  (Asked by: username_0 on 2020-08-24)
  
  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,
  username_0
  
  **Tags:** civicase, activity
  
  > **Comments:**
  > **username_1**: a non-dev CMS dependent option might be to achieve this part of your workflow via Drupal Views  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-09-16. Score: 2 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_1**: 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  
  
  ---
  
  ### Answer by username_2 on 2020-08-24. Score: 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);
  
  HTH
  Pradeep
  
  > **Comments:**
  > **username_0**: Thank you, I will work myself into that!  
  > **username_0**: 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?  
  > **username_2**: I mean something like creating class https://gist.github.com/pradpnayak/c3152131f857ce2e80fcf79fa4df22be and changing the where clause in getCaseActivity() as per your needs  
  
  ---
  
  