Delete record related by a 1 to N relationship of a module with itself #4816

Open
opened 2026-02-20 16:24:27 -05:00 by deekerman · 0 comments
Owner

Originally created by @SinergiaCRM on GitHub (Jul 26, 2022).

Issue

When we have a 1 to N relationship between a module with itself and we relate two records through the relationship, if we delete the record indicated in the field generated by the relationship, the relationship is not deleted.

Later, editing and saving the undeleted record throws an error in the relationship field because the relationship was not deleted when the record it pointed to was deleted.

Saving the record can be done by clicking on the cross of the related field to indicate that it is no longer related, but in the next edition of the record the error occurs again

RemoveRelationshipsBetweenTheSameModule

Expected Behavior

After deleting the record indicated by the field created by the relationship, as with 1 to N relationships between different modules, the relationship had to be deleted

Actual Behavior

After deleting the record indicated by the field created by the 1 to N relationship between the same modules, the relationship is not deleted.

Steps to Reproduce

  1. Create a 1 to N relationship between Contacts and Contacts or with another module with itself
  2. Create two Contacts records and relate them via the above relationship
  3. Delete the record indicated by the field created in the relationship
  4. Verify that the relationship has not been deleted via the database or by editing the record not deleted and saving, you will see an error in the relationship field.
  5. Edit and save the undeleted record N times and check that with each edit the error still appears

Possible Fix

We think that:

Context

We think it is important since the CRM remains in a state of inconsistency and the error continues when saving the record is very inconvenient

Your Environment

SuiteCRM Version used: Version 7.12.6
Browser name and version: Versión 100.0.4896.88 (Build oficial) (64 bit
Environment name and version: MySQL, PHP 7
Operating System and version: Ubuntu 20.04

Originally created by @SinergiaCRM on GitHub (Jul 26, 2022). #### Issue When we have a 1 to N relationship between a module with itself and we relate two records through the relationship, if we delete the record indicated in the field generated by the relationship, the relationship is not deleted. Later, editing and saving the undeleted record throws an error in the relationship field because the relationship was not deleted when the record it pointed to was deleted. Saving the record can be done by clicking on the cross of the related field to indicate that it is no longer related, but in the next edition of the record the error occurs again ![RemoveRelationshipsBetweenTheSameModule](https://user-images.githubusercontent.com/61022311/180966926-09d92ae3-956d-4aee-b3d7-a48296d8224e.gif) #### Expected Behavior After deleting the record indicated by the field created by the relationship, as with 1 to N relationships between different modules, the relationship had to be deleted #### Actual Behavior After deleting the record indicated by the field created by the 1 to N relationship between the same modules, the relationship is not deleted. #### Steps to Reproduce 1. Create a 1 to N relationship between Contacts and Contacts or with another module with itself 2. Create two Contacts records and relate them via the above relationship 3. Delete the record indicated by the field created in the relationship 4. Verify that the relationship has not been deleted via the database or by editing the record not deleted and saving, you will see an error in the relationship field. 5. Edit and save the undeleted record N times and check that with each edit the error still appears ### Possible Fix We think that: - The bug is related to the process of saving the 1 to N relationships between a module with itself: https://github.com/salesagility/SuiteCRM/blob/master/data/SugarBean.php#L2824-L2833 - A solution might have to do with the getSide() function of the Link2 class: https://github.com/salesagility/SuiteCRM/blob/master/data/Link2.php#L306 #### Context We think it is important since the CRM remains in a state of inconsistency and the error continues when saving the record is very inconvenient #### Your Environment SuiteCRM Version used: Version 7.12.6 Browser name and version: Versión 100.0.4896.88 (Build oficial) (64 bit Environment name and version: MySQL, PHP 7 Operating System and version: Ubuntu 20.04
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#4816
No description provided.