Answers.Body: <p>Civi Case Types cannot be deleted while there are Cases of that Type. Cases can be changed to a different Case Type which can then permit you to delete a Case Type with no Cases.
  But if you just want the Civi Cases gone then note that Civi Cases themselves, when 'deleted', remain in the system for audit purposes.
  To delete a Civi Case entirely it is necessary to do so either via the API Explorer (at /civicrm/api/explorer) or via sql.</p>
  <p>Via API Explorer use
  CRM.api('case', 'delete', {'id' : xxx});</p>
  <p>Via MySQL use</p>
  <pre><code>DELETE c, ca, a FROM 
  civicrm_case c LEFT JOIN
  civicrm_case_activity ca ON c.id = ca.case_id
  LEFT JOIN civicrm_activity a ON ca.activity_id = c.id
  WHERE case_id = xxx;
  </code></pre>
  <p>plus need to deal with case_contacts and rows in civicrm_relationships that have case_id</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-03-29T22:55:17.500Z
Answers.LastActivityDate: 2024-10-25T22:07:11.630Z
Answers.LastEditDate: 2024-10-25T22:07:11.630Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>If I need to delete a CiviCase Type or a CiviCase it can be confusing given that 'deleted' Cases are not actually removed from the db. </p>
  
Tags: <civicase>
Title: How should I delete a CiviCase or a Case Type
ThreadText: # How should I delete a CiviCase or a Case Type
  
  (Asked by: username_0 on 2015-03-29)
  
  If I need to delete a CiviCase Type or a CiviCase it can be confusing given that 'deleted' Cases are not actually removed from the db.
  
  **Tags:** civicase
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-03-29. Score: 6
  
  Civi Case Types cannot be deleted while there are Cases of that Type. Cases can be changed to a different Case Type which can then permit you to delete a Case Type with no Cases.
  But if you just want the Civi Cases gone then note that Civi Cases themselves, when 'deleted', remain in the system for audit purposes.
  To delete a Civi Case entirely it is necessary to do so either via the API Explorer (at /civicrm/api/explorer) or via sql.
  
  Via API Explorer use
  CRM.api('case', 'delete', {'id' : xxx});
  
  Via MySQL use
  
  ```
  DELETE c, ca, a FROM 
  civicrm_case c LEFT JOIN
  civicrm_case_activity ca ON c.id = ca.case_id
  LEFT JOIN civicrm_activity a ON ca.activity_id = c.id
  WHERE case_id = xxx;
  
  ```
  
  plus need to deal with case\_contacts and rows in civicrm\_relationships that have case\_id
  
  
  ---
  
  