Surveys - Deleting records from related modules in cascade #4786

Open
opened 2026-02-20 16:23:54 -05:00 by deekerman · 1 comment
Owner

Originally created by @SinergiaCRM on GitHub (Jun 17, 2022).

The Surveys module has several related module that are totally dependent from it. When deleting a Survey, none of the related records are deleting, leaving them orphans, with deleted=0 in the database. These might cause confusion if other tools are using the information directly from the database.

Issue

Orphans records remain when deleting surveys

Expected Behavior

Records should be deleted if they won't be used in any case

Actual Behavior

Orphan records remain unused

Possible Fix

We propose to override the function mark_deleted in each module bean and apply certain logic.

Modules involved:
1 - Surveys (It can be accessed from the UI)
2 - SurveyQuestions
3 - SurveyQuestionOptions
4 - SurveyResponses (It can be accessed from the UI)
5 - SurveyQuestionResponses

When deleting a record from a module, they should be deleted in cascade the records from the next modules:

  • If we delete records from the module 1, the related records from the modules 2 and 3 should be deleted in cascade, but only if the surveys deleted don't have any related answer
  • if we delete records from the module 2, the related records from the module 3 should be deleted (this can only happen if the Survey wasn't publish public)
  • If we delete records from the module 4, the related records from the module 5 should be deleted

Steps to Reproduce

  1. Create Survey with questions
  2. Delete de Survey
  3. Check in the database that the Questions stays with delete=0

Context

This can pollute the database.

Your Environment

SuiteCRM Version used: Version 7.12.6
Browser name and version: Chrome Versión 100.0.4896.88 (Build oficial) (64 bits), Firefox 100.0
Environment name and version: MySQL, PHP 7.4
Operating System and version: Ubuntu 20.04

Originally created by @SinergiaCRM on GitHub (Jun 17, 2022). The Surveys module has several related module that are totally dependent from it. When deleting a Survey, none of the related records are deleting, leaving them orphans, with deleted=0 in the database. These might cause confusion if other tools are using the information directly from the database. #### Issue Orphans records remain when deleting surveys #### Expected Behavior Records should be deleted if they won't be used in any case #### Actual Behavior Orphan records remain unused #### Possible Fix We propose to override the function mark_deleted in each module bean and apply certain logic. Modules involved: 1 - Surveys (It can be accessed from the UI) 2 - SurveyQuestions 3 - SurveyQuestionOptions 4 - SurveyResponses (It can be accessed from the UI) 5 - SurveyQuestionResponses When deleting a record from a module, they should be deleted in cascade the records from the next modules: - If we delete records from the module 1, the related records from the modules 2 and 3 should be deleted in cascade, but only if the surveys deleted don't have any related answer - if we delete records from the module 2, the related records from the module 3 should be deleted (this can only happen if the Survey wasn't publish public) - If we delete records from the module 4, the related records from the module 5 should be deleted #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Create Survey with questions 2. Delete de Survey 3. Check in the database that the Questions stays with delete=0 #### Context This can pollute the database. #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> SuiteCRM Version used: Version 7.12.6 Browser name and version: Chrome Versión 100.0.4896.88 (Build oficial) (64 bits), Firefox 100.0 Environment name and version: MySQL, PHP 7.4 Operating System and version: Ubuntu 20.04
Author
Owner

@samus-aran commented on GitHub (Jul 6, 2022):

@SinergiaCRM Should there be an option and/or disclaimer to allow the user to choose upon deleting the Survey? I understand your perspective that there is no reason to have these related sub-records. I'm just interested if we do this for other interlinked relationships e.g. Projects + Project Tasks or Workflows + Workflow Actions, Quotes + Line items.

@samus-aran commented on GitHub (Jul 6, 2022): @SinergiaCRM Should there be an option and/or disclaimer to allow the user to choose upon deleting the Survey? I understand your perspective that there is no reason to have these related sub-records. I'm just interested if we do this for other interlinked relationships e.g. Projects + Project Tasks or Workflows + Workflow Actions, Quotes + Line items.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4786
No description provided.