Results 1 to 4 of 4

Thread: problem creating one-to-may relationship in custom module

  1. #1
    manishbunty31 is offline Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default problem creating one-to-may relationship in custom module

    hi

    i have created a custom module deposit and another custom module deposit_detail.I want to create a one-to-many relationship from deposit to deposit_detail using the id field of the deposit module.Can someone help me doing this i am creating the code myself and i am not using module builder.........

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: problem creating one-to-may relationship in custom module

    Can you explain why to create the relationship by hand instead of by Studio?

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    manishbunty31 is offline Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default Re: problem creating one-to-may relationship in custom module

    actually we have a skeleton of a code that is given to us by customer in which he has done the relationship mapping by coding.While building the relationship in studio by default there is mapping of the name field from deposit to deposit_detail while the customer wants to map the id field with the id field i.e. in the select field he wants the id of the deposit to be present instead of the name filed that comes in.......

    i am pasting the code where the relationship has been created......this is the code for the vardefs.php file in the deposit module "Eqix" is the name of the package

    <?php $dictionary['Eqix_Deposit'] = array(
    'table'=>'eqix_deposit',
    'audited'=>true,
    'unified_search' => true,
    'duplicate_merge' => true,

    'fields'=>array (
    'slip_no' => array (
    'name' => 'slip_no',
    'vname' => 'LBL_SLIP_NO',
    'type' => 'varchar',
    'len' => 6,
    'required'=>false,
    'reportable'=>false,
    'audited'=>true,
    ),
    'year' => array (
    'name' => 'year',
    'vname' => 'LBL_YEAR',
    'type' => 'int',
    'len' => 4,
    'required'=>false,
    'reportable'=>false,
    'audited'=>true,
    'disable_num_format' => true,
    ),
    'month' => array (
    'name' => 'month',
    'vname' => 'LBL_MONTH',
    'type' => 'int',
    'len' => 2,
    'required'=>false,
    'reportable'=>false,
    'audited'=>true,
    ),
    'managed_day' => array (
    'name' => 'managed_day',
    'vname' => 'LBL_MANAGED_DAY',
    'type' => 'date',
    'required'=>false,
    'reportable'=>false,
    'audited'=>true,
    ),
    'user_id' => array (
    'name' => 'user_id',
    'vname' => 'LBL_USER_ID',
    'type' => 'id',
    'required'=>true,
    'reportable'=>false,
    'audited'=>true,
    ),
    'amount_plan' => array (
    'name' => 'amount_plan',
    'vname' => 'LBL_AMOUNT_PLAN',
    'type' => 'int',
    'len' => 9,
    'required'=>false,
    'reportable'=>false,
    'audited'=>true,
    ),
    'amount_total' => array (
    'name' => 'amount_total',
    'vname' => 'LBL_AMOUNT_TOTAL',
    'type' => 'int',
    'len' => 9,
    'required'=>false,
    'reportable'=>false,
    'audited'=>true,
    ),
    'details' => array (
    'name' => 'details',
    'type' => 'link',
    'relationship' => 'deposit_details',
    'source' => 'non-db',
    'vname' => 'LBL_DETAILS',
    ),
    'amount_uncollected' => array (
    'name' => 'amount_uncollected',
    'type' => 'int',
    'function' => array (
    'name' => 'getAmountUncollected',
    'returns' => 'html',
    'include' => 'modules/Eqix_Deposit/CustomCode.php',
    ),
    'source' => 'non-db',
    'len' => 9,
    ),
    'company_name' => array (
    'name' => 'company_name',
    'rname' => 'user_company_name',
    'id_name' => 'user_id',
    'vname' => 'LBL_COMPANY_NAME',
    'type' => 'relate',
    'link' => 'user_deposits',
    'table' => 'eqix_usermaster',
    'isnull' => 'true',
    'module' => 'Eqix_UserMaster',
    'source' => 'non-db',
    ),
    'user_deposits' => array (
    'name' => 'users',
    'type' => 'link',
    'relationship' => 'deposit_user',
    'module' => 'Eqix_UserMaster',
    'bean_name' => 'Eqix_UserMaster',
    'source' => 'non-db',
    'vname' => 'LBL_USER_DEPOSITS',
    )
    ),
    'relationships'=>array (
    'deposit_details' => array (
    'lhs_module' => 'Eqix_Deposit',
    'lhs_table' => 'eqix_deposit',
    'lhs_key' => 'id',
    'rhs_module' => 'Eqix_DepositDetail',
    'rhs_table' => 'eqix_depositdetail',
    'rhs_key' => 'detail_id',
    'relationship_type' => 'many-to-many',
    ),
    'deposit_user' => array (
    'lhs_module' => 'Eqix_Deposit',
    'lhs_table' => 'eqix_deposit',
    'lhs_key' => 'user_id',
    'rhs_module' => 'Eqix_UserMaster',
    'rhs_table' => 'eqix_usermaster',
    'rhs_key' => 'id',
    'relationship_type' => 'one-to-many',
    ),
    ),
    'optimistic_lock'=>true,
    );
    require_once('include/SugarObjects/VardefManager.php');
    VardefManager::createVardef('Eqix_Deposit','Eqix_D eposit', array('default','assignable'));
    ?>

    Kindly help on this and explain how can we solve this problem
    Last edited by manishbunty31; 2009-07-11 at 07:53 AM. Reason: missed a line

  4. #4
    manishbunty31 is offline Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default Re: problem creating one-to-may relationship in custom module

    i have also performed the steps from the link below

    http://www.sugarcrm.com/wiki/index.p...e_CHILD_module

    but i have not been able to solve the problem..kindly give help me with the code i have given you....

    the code for editviewdefs.php for the deposit_detail module is written below:
    <?php
    $module_name = 'Eqix_DepositDetail';
    $viewdefs[$module_name]['EditView'] = array(
    'templateMeta' => array('maxColumns' => '2',
    'widths' => array(
    array('label' => '10', 'field' => '30'),
    array('label' => '10', 'field' => '30')
    ),
    ),


    'panels' =>array (
    'default' =>
    array (

    array (
    'slip_no',
    'column_no',
    ),
    array (
    'kind_money',
    'amount_money',
    ),
    array (
    'detail_id',
    ),
    ),

    ),

    );
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2009-04-24, 08:43 AM
  2. custom modules relationship problem
    By shailendra001 in forum Developer Help
    Replies: 1
    Last Post: 2008-11-27, 12:03 AM
  3. Replies: 2
    Last Post: 2008-10-29, 01:09 AM
  4. weird problem creating 1-many relationship
    By mikesolomon in forum Developer Help
    Replies: 0
    Last Post: 2008-07-04, 10:34 AM
  5. Replies: 2
    Last Post: 2008-01-14, 05:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •