Hi all,

I need to setup a Contacts subpanel in my custom Suppliers module. I reviewed the Cases/Contacts relationship already built into Sugar and I tried to duplicate the functionality in my module. All worked ok, except one thing: the quick create form in my module's Contacts subpanel. When I click the 'Create' button the Contacts quick create form appears correctly but when I click 'Save', code does not link the newly created contact with my supplier_id, although the contact is created ok in 'contacts' table. I have to 'Select' the contact to link the 'contact_id' with 'supplier_id' in the 'contacts_suppliers' table. As I already said the relationship was guided by the similar Cases/Contacts relationship where the quick create form works ok.
Looking at the sugarcrm.log and comparing the logs produced when saving a contact from a Case and then from a Supplier, it seems that the Contacts/Save.php is not aware of 'contacts_suppliers' relationship. But I have defined the relationship in Contacts vardefs during Suppliers installation as shown below. What am I missing? Plz, anyone guide me to right place to look for.
Below are the definitions of the relationship:

Suppliers/vardefs.php:
PHP Code:
$dictionary['Supplier']['fields']['contacts'] = array(
   
'name'        => 'contacts',
   
'type'          => 'link',
   
'source'        => 'non-db',
   
'relationship'    => 'contacts_suppliers',
   
'vname'        => 'LBL_CONTACTS',
  ) 
relationships/contacts_suppliersMetaData.php:
PHP Code:
$dictionary['contacts_suppliers'] = array (
    
'table' => 'contacts_suppliers',
    
'fields' => array (
        array(
'name' => 'id''type' => 'varchar''len' => '36''required' => true'default' => ''),
        array(
'name' => 'deleted''type' => 'bool''len'=> '1''required' => true'default'=> '0'),
        array(
'name' => 'date_modified''type' => 'datetime'),
        array(
'name' => 'supplier_id''type' => 'varchar''len' => '36''required' => true'default' => ''),
        array(
'name' => 'contact_id''type' => 'varchar''len' => '36''required' => true'default' => '')
    ),
    
'indices' => array (
        array(
            
'name' => 'contacts_suppliers_pk',
            
'type' => 'primary',
            
'fields' => array('id')
        ),
        array(
            
'name' => 'idx_supplier',
            
'type' => 'index',
            
'fields' => array('supplier_id')
        ),
        array(
            
'name' => 'idx_contact'    ,
            
'type' => 'index',
            
'fields' => array('contact_id')
        ),
        array(
            
'name' => 'idx_contacts_suppliers',
            
'type' => 'alternate_key',
            
'fields' => array(
                
'contact_id',
                
'supplier_id',
            )
        )
    ),
    
'relationships' => array(
        
'contacts_suppliers' => array(
            
'lhs_module' => 'Contacts',
            
'lhs_table' => 'contacts',
            
'lhs_key' => 'id',
            
'rhs_module' => 'Suppliers',
            
'rhs_table' => 'suppliers',
            
'rhs_key' => 'id',
            
'join_table' => 'contacts_suppliers',
            
'join_key_lhs' => 'contact_id',
            
'join_key_rhs' => 'supplier_id',
            
'relationship_type' => 'many-to-many',
        )
    )
); 
Suppliers/layout_defs.php:
PHP Code:
$layout_defs['Suppliers']['contacts'] =  array(
            
'order' => 20,
            
'module' => 'Contacts',
            
'sort_order' => 'asc',
            
'sort_by' => 'last_name, first_name',
            
'subpanel_name' => 'default',
            
'get_subpanel_data' => 'contacts',
            
'add_subpanel_data' => 'contact_id',
            
'title_key' => 'LBL_CONTACTS_SUBPANEL_TITLE',
            
'top_buttons' => array(
                array(
'widget_class' => 'SubPanelTopCreateAccountNameButton'),
                array(
'widget_class' => 'SubPanelTopSelectButton''mode' => 'MultiSelect')
            ),

        ) 
vardefs/contacts_vardefs.php:
PHP Code:
$dictionary['Contact']['fields']['suppliers'] =   array (
    
'name' => 'suppliers',
    
'type' => 'link',
    
'relationship' => 'contacts_suppliers',
    
'source' => 'non-db',
    
'vname' => 'LBL_SUPPLIERS',
); 
manifest.php:
PHP Code:
$installdefs['relationships'] = array (
   array (
        
'module' => 'Contacts',
        
'meta_data'    => '<basepath>/relationships/contacts_suppliersMetaData.php',
        
'module_vardefs' => '<basepath>/vardefs/contacts_vardefs.php'
    
)

Thank you for any help.

SugarCRM OS Version 4.5.1 (Build 1197)
Windows XP Pro SP2
Apache Server 2.2.3
PHP 5.2.0
MySQL 5.0.27