AnsweredAssumed Answered

How to add a M-N relationship via vardefs?

Question asked by Francesca Shiekh on Oct 9, 2014
Latest reply on Oct 12, 2015 by Francesca Shiekh
I am trying to add a relationship between a custom module (Mass Interactions) and EmailAddresses, and to so in such a way that it won't need to be redone in v7.5.x when we go there.

The examples I can find are all 1-M and not N-M.

in 

custom/Extension/modules/massi_Mass_Interactions/Vardefs
I added the non-db link field and the relationship:
<?php
$dictionary["massi_Mass_Interactions"]["fields"]["email_addr"] = array (
  'name' => 'email_addr',
  'type' => 'link',
  'relationship' => 'massi_email_addr_rel',
  'source' => 'non-db',
  'vname' => 'LBL_MASSI_EMAIL_ADDR_REL_FROM_EMAILADDR_TITLE',
);
$dictionary["massi_Mass_Interactions"]["relationships"]["massi_email_addr_rel"] = array(
        'lhs_module'=> 'massi_Mass_Interactions'
      , 'lhs_table'=> 'massi_mass_interactions'
      , 'lhs_key' => 'id'
      , 'rhs_module'=> 'EmailAddresses'
      , 'rhs_table'=> 'email_addresses'
      , 'rhs_key' => 'id'
      , 'relationship_type'=>'many-to-many'
      , 'join_table'=> 'email_addr_massi_rel'
      , 'join_key_lhs'=>'mass_interaction_id'
      , 'join_key_rhs'=>'email_address_id'
);
?>


 


and in custom/Extension/modules/EmailAddresses/Ext/Vardefs/vardefs.ext.php 

<?php
$dictionary["EmailAddresses"]["fields"]["massi_mass_interactions"] = array (
  'name' => 'massi_mass_interactions',
  'type' => 'link',
  'relationship' => 'massi_email_addr_rel',
  'source' => 'non-db',
  'vname' => 'LBL_MASSI_EMAIL_ADDR_REL_FROM_MASSI_TITLE',
);
?>


  I ran repair/rebuild but it's not prompting to create the relationship table, do I need to do that in sql? Am I missing something?. 

thanks,


Francesca

PS. I know all about campaigns & targets, we just don't want these in campaigns or targets; and I know I could use a Person template to create my Mass Interactions module and put all these relationships in email_addr_bean_rel but I'd like to keep them separate and not load up that table.

thanks,


FrancescaS

Outcomes