Reputation: 579
In the Module Builder, let's say I want to add custom modules Pets and Visits for my pet grooming salon.
If I want to be able to access Visits from a logic hook in the Pets module, and also Pets from Visits, and I also want to show each one as a panel in the other, should I:
I don't know if the answer's the same for Sugar; I think there might be a different "module builder" sort of thing for it.
Upvotes: 1
Views: 877
Reputation: 3950
As far as Sugar is concerned you'd want a many-to-many relationship if you want a panel in both modules.
However if you want to limit the relationship to a maximum of one Pet per Visit, then a one-to-many relationship is appropriate with Pet as primary module (L) and Visits as related Module (R). Please note that in Visits the related Pet will possibly not be displayed as panel but as a relate field for such a relationship (at least in EditView, in Record View it probably is still displayed as Panel in SuiteCRM as it uses the old UI of Sugar).
Either way a relationship can always be accessed from both sides, so you don't need a second relationship)
Further info: https://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Understanding_Relationship_Creation_Options/
PS: If you want a one-to-many relationship but a panel even on the side where only one record of the other module can be linked to most at any time, then you can probably achieve this by creating a many-to-many relationship first and adjust the relationship's metadata to have true_relationship_type
as one-to-many
in code.
Upvotes: 2