Answers.Body: <p>This is coming from the db schema. There's a delete cascade constraint on parent_id. You could remove that constraint but it might be used elsewhere for different types of activity-pairing (not followup related)  to enforce data consistency. Would have to review all the activity-related code that uses parent_id. It's also possible that parent_id for this pair of activities is never used again anywhere,  so another possibility is remove that linking for followups (via some code, either override or extension), but again would need to review.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-21T16:29:10.483Z
Answers.Text: Thanks Demerit
  
  Where would I start looking for those settings?
  
  Cheers
  
  Craig
Answers.UserDisplayName: Craig Almond
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-22T00:01:53.730Z
Answers.Text: I see your comment about change of plans but for anyone else looking: To review, use for example "grep -r parent_id *" in the civi folder and see what comes up. If doing the first option to remove the constraint, "ALTER TABLE civicrm_activity DROP FOREIGN KEY FK_civicrm_activity_parent_id". For the second, one way is to write an extension and use hook_civicrm_post to set the parent_id to null when it's a followup. https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-22T07:52:55.327Z
Answers.Text: Altering the schema for an individual database without reviewing all the activity-related code that uses parent_id sounds fairly risky. Using hook_civicrm_post to set the parent_id to null when it's a followup, or alternatively using a pre hook to null any parent ids in children before nulling the parent sounds less risky (off the top of my head).
Answers.UserDisplayName: michaelmcandrew
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-20T23:26:12.653Z
Answers.LastActivityDate: 2017-11-20T23:26:12.653Z
Answers.UserDisplayName: Demerit
Body: <p>Apologies if this has been asked before. It's been a long day and I can't see anything similar in search results.</p>
  
  <p>When using schedule follow up activity to create an activity, the  follow up activity is deleted when the original is deleted. (Currently happening in 4.6)</p>
  
  <p>I've not seen this happening on other installs (then again, I've never looked).</p>
  
  <p>Is there a way to stop this happening, a magic button I'm overlooking?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-20T21:54:53.330Z
Comments.Text: Are the initial Activities being deleted on purpose - if so why - or accidentally?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-21T16:27:52.710Z
Comments.Text: It's a mentoring service for ex offenders.
  
  Staff can view and update mentors and mentees
  
  Mentors can only update their own mentees (permissioned relationships)
  
  Some mentors are creating duplicate activities because they can't see/ update activities added by staff.
  
  Staff are then "tidying up records" by deleting one of the duplicated activities, which is causing follow up activities to disappear.
  
  I've not seen the issue elsewhere because the duplication of activities doesn't happen in the same fashion/ at the same rate.
Comments.UserDisplayName: Craig Almond
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-21T16:28:30.823Z
Comments.Text: The organisation has now decided to not delete duplicated activities but to use an additional status to take them out of reports.
Comments.UserDisplayName: Craig Almond
Tags: <activities><scheduled-follow-up>
Title: How to stop CiviCRM deleting a scheduled follow up activity when the original activity is deleted
ThreadText: # How to stop CiviCRM deleting a scheduled follow up activity when the original activity is deleted
  
  (Asked by: username_0 on 2017-11-20)
  
  Apologies if this has been asked before. It's been a long day and I can't see anything similar in search results.
  
  When using schedule follow up activity to create an activity, the follow up activity is deleted when the original is deleted. (Currently happening in 4.6)
  
  I've not seen this happening on other installs (then again, I've never looked).
  
  Is there a way to stop this happening, a magic button I'm overlooking?
  
  **Tags:** activities, scheduled-follow-up
  
  > **Comments:**
  > **username_1**: Are the initial Activities being deleted on purpose - if so why - or accidentally?  
  > **username_0**: It's a mentoring service for ex offenders.  Staff can view and update mentors and mentees  Mentors can only update their own mentees (permissioned relationships)  Some mentors are creating duplicate activities because they can't see/ update activities added by staff.  Staff are then "tidying up records" by deleting one of the duplicated activities, which is causing follow up activities to disappear.  I've not seen the issue elsewhere because the duplication of activities doesn't happen in the same fashion/ at the same rate.  
  > **username_0**: The organisation has now decided to not delete duplicated activities but to use an additional status to take them out of reports.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-11-20. Score: 1
  
  This is coming from the db schema. There's a delete cascade constraint on parent\_id. You could remove that constraint but it might be used elsewhere for different types of activity-pairing (not followup related) to enforce data consistency. Would have to review all the activity-related code that uses parent\_id. It's also possible that parent\_id for this pair of activities is never used again anywhere, so another possibility is remove that linking for followups (via some code, either override or extension), but again would need to review.
  
  > **Comments:**
  > **username_0**: Thanks username_2  Where would I start looking for those settings?  Cheers  Craig  
  > **username_2**: I see your comment about change of plans but for anyone else looking: To review, use for example "grep -r parent_id *" in the civi folder and see what comes up. If doing the first option to remove the constraint, "ALTER TABLE civicrm_activity DROP FOREIGN KEY FK_civicrm_activity_parent_id". For the second, one way is to write an extension and use hook_civicrm_post to set the parent_id to null when it's a followup. https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/  
  > **username_3**: Altering the schema for an individual database without reviewing all the activity-related code that uses parent_id sounds fairly risky. Using hook_civicrm_post to set the parent_id to null when it's a followup, or alternatively using a pre hook to null any parent ids in children before nulling the parent sounds less risky (off the top of my head).  
  
  ---
  
  