Answers.Body: <p>Interesting question ... if they were disabled, it would make restoring the contacts a bit more complicated since it would need to figure out which relationships to re-enable. But disabling certainly seems reasonable.</p>
  <p>As a workaround, you could write custom code using <code>hook_civicrm_post</code> to disable them, or probably do something with CiviRules.</p>
  <p>It's probably worth creating an issue to get wider discussion.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-20T17:53:53.450Z
Answers.Text: Yep we have hit this when building Views and SearchKits so have to remember to specify 'contact is deleted = NO'
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-21T09:04:48.063Z
Answers.Text: I use hook_civicrm_postCommit for altering one of Individuals  custom field value. Since Individuals can have multiple Organization relationships, each time an Organization is deleted we check if there are any active Relationship left and change the field value if there are none. And this is where things get complicated: the Organization is deleted but the Relationship stays active. I think the simultaneous Relationship  disable would be an answer here.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-20T17:43:52.407Z
Answers.LastActivityDate: 2023-12-20T17:43:52.407Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>It looks like that changed when the contact summary &quot;Relationships&quot; tab was replaced with a SearchKit version.</p>
  <p>I've submitted <a href="https://github.com/civicrm/civicrm-core/pull/28737" rel="nofollow noreferrer">this PR</a> to fix it and hide deleted contacts from that tab.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-21T09:13:33.567Z
Answers.Text: Thank you, this will make things less confusing. Why "hide" and not move under the  "Inactive"?
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-21T17:20:24.407Z
Answers.Text: Because the contacts do not exist except in the trash, so they should not be shown anywhere in the UI.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-26T16:08:39.640Z
Answers.Text: We have noticed the same issue and are puzzled. Maybe if Relationships are hidden because the contact went into Trash, there should be some way of identifying it, so if the contact is recovered, the relationships can be restored to their prior state.
Answers.UserDisplayName: Stephen Palmstrom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-26T23:11:03.153Z
Answers.Text: You ought to be able to still view the deleted contact and click on their Relationships tab and see their relationships.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-20T19:17:28.000Z
Answers.LastActivityDate: 2023-12-20T19:17:28.000Z
Answers.UserDisplayName: Coleman
Body: <p>Have just discovered ( and confirmed on <a href="https://wpmaster.demo.civicrm.org" rel="nofollow noreferrer">https://wpmaster.demo.civicrm.org</a> ) that Relationships of a deleted Contact are continue to be active and are displayed as such.</p>
  <p>Not quite sure if it is a bug or a feature? Why would Relationships with deleted Contacts be kept active? Shouldn't the system at least disable them?</p>
  <p><a href="https://i.sstatic.net/svQRB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/svQRB.png" alt="enter image description here" /></a></p>
  
Tags: <relationships><delete>
Title: Why would related contact deletion keeps a Relationship active?
ThreadText: # Why would related contact deletion keeps a Relationship active?
  
  (Asked by: username_0 on 2023-12-20)
  
  Have just discovered ( and confirmed on <https://wpmaster.demo.civicrm.org> ) that Relationships of a deleted Contact are continue to be active and are displayed as such.
  
  Not quite sure if it is a bug or a feature? Why would Relationships with deleted Contacts be kept active? Shouldn't the system at least disable them?
  
  [![enter image description here](https://i.sstatic.net/svQRB.png)](https://i.sstatic.net/svQRB.png)
  
  **Tags:** relationships, delete
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-12-20. Score: 2 | Accepted answer
  
  Interesting question ... if they were disabled, it would make restoring the contacts a bit more complicated since it would need to figure out which relationships to re-enable. But disabling certainly seems reasonable.
  
  As a workaround, you could write custom code using `hook_civicrm_post` to disable them, or probably do something with CiviRules.
  
  It's probably worth creating an issue to get wider discussion.
  
  > **Comments:**
  > **username_2**: Yep we have hit this when building Views and SearchKits so have to remember to specify 'contact is deleted = NO'  
  > **username_0**: I use hook_civicrm_postCommit for altering one of Individuals  custom field value. Since Individuals can have multiple Organization relationships, each time an Organization is deleted we check if there are any active Relationship left and change the field value if there are none. And this is where things get complicated: the Organization is deleted but the Relationship stays active. I think the simultaneous Relationship  disable would be an answer here.  
  
  ---
  
  ### Answer by username_3 on 2023-12-20. Score: 4
  
  It looks like that changed when the contact summary "Relationships" tab was replaced with a SearchKit version.
  
  I've submitted [this PR](https://github.com/civicrm/civicrm-core/pull/28737) to fix it and hide deleted contacts from that tab.
  
  > **Comments:**
  > **username_0**: Thank you, this will make things less confusing. Why "hide" and not move under the  "Inactive"?  
  > **username_3**: Because the contacts do not exist except in the trash, so they should not be shown anywhere in the UI.  
  > **username_4**: We have noticed the same issue and are puzzled. Maybe if Relationships are hidden because the contact went into Trash, there should be some way of identifying it, so if the contact is recovered, the relationships can be restored to their prior state.  
  > **username_3**: You ought to be able to still view the deleted contact and click on their Relationships tab and see their relationships.  
  
  ---
  
  