I have a custom module ("cMod") (based on opportunities) and I want to create a relationship with itself. So can I have a 1 to many relationship between "cMod" (1) --> cMod (many)?
If so, what are the pitfalls if any?
Thanks in advance
It's possible to do it in studio. There are already 1-many relationships in SugarCRM between a module and itself. For example, Accounts has a 1-many relationship to itself (the member_accounts relationship). So for example let's say you deal with the local London branch of Google, but you also deal with the Google in Paris, and you want to relate them both to the Google in Mountain View (which is the head branch), all three of them would be 'Accounts', and there'd be a one to many - London and Paris would be children accounts of the Mountain View Google.
What problem are you trying to solve? Maybe then I can give more detailed information.
You answered this well, thank you.
the problem I'm solving is that we have a notion of a blanket Opportunity. Let's say "any services up to $100K". then we want to create a set of "sub-opportunities", that eat into the blanket opportunity. So if we render a service for 20K, we will make a separate "child" opportunity underneath the "parent".
I used the "relate" field, and it shows the parent in the child record, but if you go to the parent you won't see all the related children.
The concern that I have is that the custom opportunity model has not had a self-referential relationship to date. If I make that change now, are there any repercussions?
You have a couple of options:
- keep the relate field for your parent opportunity and create a dashlet in your Opportunities Intelligence Pane to get a list of children.
- You if you haven't deployed it yet, i.e. have no data in that field, you can remove the relate field and instead create a 1-M relationship so that you'll have both a parent relate field on the Opp and a subpanel with related Opps on each Opp.
I don't think there are repercussions with either approach.
One thought based on your example, have you considered having a dropdown on the Opportunity instead? Some kind of Opportunity Classification that tags the Opportunity as "Services up to 100K" on which you can then search and report? It's just a thought without really knowing your business model and user-needs, it may not fit your scenario at all.
I would prefer a sub-panel of child opps which would lead me to the 1 to many self referencing relationship. I will try doing this in a test instance
Thanks for the help
Are these 20k opportunities part of the 100k opportunities? Or are they separate? The reason I ask is if they're part of it (e.g. renovating somebody's house, with 20k for the kitchen) is that if you total your opportunities, you'll end up with 120k total (which isn't correct - these are line items on the main opportunity and you should consider a separate module). If they're separate opportunities there's no harm in what you're doing.
You can delete your custom relationship. If you're worried about visibility on the parent record, I'd recommend the ListView dashlet (or building your own dashlet), or seeing if you can add it as a subpanel .
agreed on the 120 problem. We will flag the first deal in such a way as to know how to handle the math properly
I would ideally like a subpanel, which would be automatic with the self-referential relationship. I may have to kluge something together to make that work using just the relate field
Appreciate everyone's help.
Retrieving data ...