SuiteCRM icon indicating copy to clipboard operation
SuiteCRM copied to clipboard

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

Open SinergiaCRM opened this issue 2 years ago • 0 comments

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:

  • 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

SinergiaCRM avatar Jul 26 '22 08:07 SinergiaCRM