Custom relationship field

hi, I created a relationship between two custom modules, Client (Host-module) - Product (Sub-module) and I’m trying to create a custom “distributor” field within the product subpanel, as explained in this video.
https://www.youtube.com/watch?v=Yr9IvECTIeo
I created a third module called “productdistributor” which contains:
-Customer id
-Product id

I have created an “after relationship add” logic hook that after selecting a record from the product sub-panel should create a record within “productdistributor”, but this does not happen, the table remains empty and I get this error:
Uncaught Error: Call to undefined method stdClass::save() in C:\xampp\htdocs\suitecrm\custom\application\Ext\Utils\custom_utils.ext.php:18

Could you please help me?
Thanks a lot.

Question. Did you created the relationship to your custom module from Studio?

Hi broz, thanks for replying, I solved this problem, I was wrong in creating the bean, however I have another problem. I am modifying the “edit” button of the cc_Prodottoo subpanel to show a custom layout.
In “custom \ Extension \ modules \ Cs_Cliente \ Ext \ Layoutdefs \ cs_cliente_cc_prodottoo_1_Cs_Cliente.php” I changed the subpanel_name from “default” to “ForCliente”.

       $layout_defs["Cs_Cliente"]["subpanel_setup"]['cs_cliente_cc_prodottoo_1'] = array (
      'order' => 100,
      'module' => 'cc_Prodottoo',
      'subpanel_name' => 'ForCliente',
      'sort_order' => 'asc',
      'sort_by' => 'id',
      'title_key' => 'LBL_CS_CLIENTE_CC_PRODOTTOO_1_FROM_CC_PRODOTTOO_TITLE',
      'get_subpanel_data' => 'cs_cliente_cc_prodottoo_1',
      'top_buttons' => 
      array (
        0 => 
        array (
          'widget_class' => 'SubPanelTopButtonQuickCreate',
        ),
        1 => 
        array (
          'widget_class' => 'SubPanelTopSelectButton',
          'mode' => 'MultiSelect',
        ),
      ),
    );

I created the “ForCliente.php” file in “custom \ modules \ cc_Prodottoo \ metadata \ subpanels” but this file is not pointed to.

// this is the ForCliente.php file
    if (!defined('sugarEntry') || !sugarEntry) {
        die('Not A Valid Entry Point');
    }

    $module_name = 'cc_Prodottoo';
    $subpanel_layout = array(
        'top_buttons' => array(
            array('widget_class' => 'SubPanelTopCreateButton'),
            array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => $module_name),
        ),

        'where' => '',

        'list_fields' => array(
            'name' => array(
                'vname' => 'LBL_NAME',
                'widget_class' => 'SubPanelDetailViewLink',
                'width' => '45%',
            ),
            'date_modified' => array(
                'vname' => 'LBL_DATE_MODIFIED',
                'width' => '45%',
            ),
              'distributore_c' => array (
             'vname' => 'LBL_DISTRIBUTORE',
             'widget_class' => 'SubPanelShowcst_DistrProdotto',
             'width' => '40%',
           ),
            'edit_button' => array(
                'vname' => 'LBL_EDIT_BUTTON',
                'widget_class' => 'SubPanelEditcst_DistributoreProdottoButton',
                'module' => 'cc_Prodottoo',
                'width' => '4%',
            ),
            'remove_button' => array(
                'vname' => 'LBL_REMOVE',
                'widget_class' => 'SubPanelRemoveButton',
                'module' => $module_name,
                'width' => '5%',
            ),
        ),
    );