Trying to create a relationship between Opportunities and Meetings and use the existing subpanel

The goal is to create a one-to-many relationship of Opportunity to Meetings (opportunity_meetings_1).

As you know, Opportunities already have such a relationship (opportunity_meetings) because Meetings has a native flex-relate field.

I know that creating a new relate field in this case would add an additional Meetings subpanel to Opportunities. That makes reports and other things awkward and a lot less practical

I need to create this Opportunity relationship field in Meetings so that when an opportunity is specified there, it is added to the same Meetings subpanel in the oppportunity record.

My installdefs currently contain this code:

$installdefs = array(
  'id' => 'Opportunity_Meetings_Relationship',
  'vardefs' => array(
      array(
          'from' => '<basepath>/vardefs_meetings.php',
          'to_module' => 'Meetings'
      ),
  ),
  'relationships' => array(
      array(
        'meta_data' => '<basepath>/opportunity_meetings_1MetaData.php'
      ),
  ),
);

Where the vardefs_meetings.phpfile defines a relationship field:

$dictionary['Meeting']['fields']['opportunities'] = array(
    'name' => 'opportunity_meetings_1',
    'type' => 'link',
    'relationship' => 'opportunity_meetings_1',
    'source' => 'non-db',
    'module' => 'Opportunities',
    'bean_name' => 'Opportunity',
    'vname' => 'LBL_OPPORTUNITIES',
    'id_name' => 'opportunity_meetings_1_id',
    'link-type' => 'one',
    'side' => 'left',
);

And I originally added all the fields and indices and everything as per the Developer Guide, but now I'm just using adjusted values that I copied from the native opportunity_meetings relationship with hope that it would use the same relationship table or something and use the same Meetings subpanel in Opportunities rather than creating yet another Meetings subpanel:

$dictionary['opportunity_meetings_1'] = array(
    'name' => 'opportunity_meetings_1',
    'lhs_module' => 'Opportunities',
    'lhs_table' => 'opportunities',
    'lhs_key' => 'id',
    'rhs_module' => 'Meetings',
    'rhs_table' => 'meetings',
    'rhs_key' => 'parent_id',
    'relationship_type' => 'one-to-many',
    'relationship_role_column' => 'parent_type',
    'relationship_role_column_value' => 'Opportunities',
);

But, alas, no subpanel is created at all and I have no Opportunity relationship field that I could place on the layout for Meetings.

Parents
  • Hi Artis,

    May I ask why you need another relationship?

    Perhaps there is a better solution to your business requirement than creating another relationship.

    You could certainly create another relationship or add a relate field but for reporting purposes it is more about where the data lives in the database than where the relationship is displayed. If you add a relationship you will have a new table, if you add a new relate field you will have a new field in the Meetings table.

    Keep in mind that subpanels are just a display of the data, and as such could be customized to include data from multiple database sources.

    If you are not familiar with the difference between a relationship, relate field, and flex relate see:

    http://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Introduction_to_Relationships_and_Relate_Fields/ 

    I hope this helps,

    FrancescaS

Reply
  • Hi Artis,

    May I ask why you need another relationship?

    Perhaps there is a better solution to your business requirement than creating another relationship.

    You could certainly create another relationship or add a relate field but for reporting purposes it is more about where the data lives in the database than where the relationship is displayed. If you add a relationship you will have a new table, if you add a new relate field you will have a new field in the Meetings table.

    Keep in mind that subpanels are just a display of the data, and as such could be customized to include data from multiple database sources.

    If you are not familiar with the difference between a relationship, relate field, and flex relate see:

    http://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Introduction_to_Relationships_and_Relate_Fields/ 

    I hope this helps,

    FrancescaS

Children
  • Hi Francesca,

    I need it to be possible to have Meetings that are related to a parent record (any module in the native flex-relate field) while also having the option to additionally relate the meeting to an opportunity.

    The most important thing is to have the meetings related to an opportunity this way appear in reports together with meetings that have been related to the opportunity in a different way (by default appearing in the one existing subpanel).