Results 1 to 4 of 4

Thread: Multiple one-to-many relationship on SAME module

  1. #1
    Join Date
    Feb 2009
    Posts
    13

    Default Multiple one-to-many relationship on SAME module

    I have 2 custom modules - referalsource and loans.

    I am in referalsource in module builder and i add a 1-many relationship (referralsource to loans). When i create one relationship i get the relate field as i wanted in the loan module, and a subpanel in the referral source module. -That works fine.

    Now i want to create the exact same relationship again, because want to have 2 relate fields in the loan modules one being referral source 1, and the second is referral source 2 (basically a primary and secondary referal. When i attempt to create another 1 to many relationship (referralsource to loans) it adds the second relate field in loans, and the second subpanel in referalsource.


    When i use the subpanels in referal sources i can add loan entries and it works fine, but when im in loan module and try to complete the two relate fields they do not save the information, and the two relate fields are now compulsory to enter before i can save the form.


    Is there any pointers on how this can work?

    when i go to the EDIT view on the loan module i see the following code (the names all appear different except the hidden field uses the same <input type="hidden" name="nwc_referraralsources_ida" id="nwc_referraralsources_ida" value=""> name.

    in the code loanliabilities refers to the loan module (ie the 2 relate fields), and referralsources refers to the another module in which i have the 2 subpanels.

    <tr>
    <td valign="top" id='nwc_referralsources_nwc_loanliabilities_name_l abel' width='12.5%' class="dataLabel" NOWRAP>
    Referral Sources:
    </td>
    <td valign="top" width='37.5%' class='tabEditViewDF' NOWRAP>
    <input type="text" name="nwc_referralsources_nwc_loanliabilities_name " class="sqsEnabled" tabindex="0" id="nwc_referralsources_nwc_loanliabilities_name" size="" value="" title='' autocomplete="off" >
    <input type="hidden" name="nwc_referraralsources_ida" id="nwc_referraralsources_ida" value="">
    <input type="button" name="btn_nwc_referralsources_nwc_loanliabilities_ name" tabindex="0" title="Select [Alt+T]" accessKey="T" class="button" value="Select" onclick='open_popup("nwc_ReferralSources", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"Ed itView","field_to_name_array":{"id":"nwc_referrara lsources_ida","name":"nwc_referralsources_nwc_loan liabilities_name"}}, "single", true);'>
    <input type="button" name="btn_clr_nwc_referralsources_nwc_loanliabilit ies_name" tabindex="0" title="Clear [Alt+C]" accessKey="C" class="button" onclick="this.form.nwc_referralsources_nwc_loanlia bilities_name.value = ''; this.form.nwc_referraralsources_ida.value = '';" value="Clear">
    <td valign="top" id='nwc_referralsources_nwc_loanliabilities_1_name _label' width='12.5%' class="dataLabel" NOWRAP>
    Referral Sources:
    </td>
    <td valign="top" width='37.5%' class='tabEditViewDF' NOWRAP>
    <input type="text" name="nwc_referralsources_nwc_loanliabilities_1_na me" class="sqsEnabled" tabindex="1" id="nwc_referralsources_nwc_loanliabilities_1_name " size="" value="" title='' autocomplete="off" >
    <input type="hidden" name="nwc_referraralsources_ida" id="nwc_referraralsources_ida" value="">
    <input type="button" name="btn_nwc_referralsources_nwc_loanliabilities_ 1_name" tabindex="1" title="Select [Alt+T]" accessKey="T" class="button" value="Select" onclick='open_popup("nwc_ReferralSources", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"Ed itView","field_to_name_array":{"id":"nwc_referrara lsources_ida","name":"nwc_referralsources_nwc_loan liabilities_1_name"}}, "single", true);'>
    <input type="button" name="btn_clr_nwc_referralsources_nwc_loanliabilit ies_1_name" tabindex="1" title="Clear [Alt+C]" accessKey="C" class="button" onclick="this.form.nwc_referralsources_nwc_loanlia bilities_1_name.value = ''; this.form.nwc_referraralsources_ida.value = '';" value="Clear">
    </tr>
    Last edited by marktaylor5151; 2009-02-12 at 04:21 AM.

  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: Multiple one-to-many relationship on SAME module

    Through Studio you only can create a single relationship between two modules.
    So you need to copy the relationship defs and modify the enough to get them different but useful.
    The relationship defs are stored into:
    custom/Extension/modules/<ModuleName>/Ext/Vardefs/
    custom/Extension/modules/<ModuleName>/Ext/Layoutdefs/
    custom/metadata/

    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
    vishwasrao's Avatar
    vishwasrao is offline A Prolific Poster
    Join Date
    Sep 2008
    Location
    Pune,Maharashtra,India
    Posts
    385

    Smile Re: Multiple one-to-many relationship on SAME module

    Vishwasrao Salunkhe
    vishwasrao.salunkhe@gmail.com
    Fan Of Sachin Tendulkar
    Operating System :- Windows XP
    PHP Version:- 5.3
    Apache :-2.2.11
    MYSQL :-5.1.36

  4. #4
    jlabuelo is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    426

    Default Re: Multiple one-to-many relationship on SAME module

    Good Afternoon all

    I have checked the last solution proposed in this post. Thanks a lot for sharing it btw. However I think I found a bug that maybe you can confirm. I have created a new Team module, that needs to be related with itself as "Parent Team". So i have followed all the steps described in the article, and yes it works...95% .

    The only error I find is that when I create a Team A, and a Team B, if I set Team A as Parent Team of Team B, in the list view I get this result:

    Team / Parent Team
    Team B / Team A
    Team A / Team B

    When I only should get this:

    Team / Parent Team
    Team B / Team A
    Team A /

    After adding "Team A" as parent Team of "TeamB" and I saw the list view, I edited "Team A" record and deleted the Parent Team = "Team B".

    Basically as a summary, I just needed to create a parent-child relationship between teams, but when I created the relationship, the system just created two parent-child relationships.... then if you delete the wrong one everything goes back to normal... but this should not be the way..

    Any pattern you find familiar or that I have followed wrong?

    Thanks a lot in advance

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 2008-08-19, 06:35 AM
  2. Replies: 2
    Last Post: 2008-07-03, 12:14 PM
  3. multiple fields on a single one-to-many relationship
    By alaaosh in forum Developer Help
    Replies: 0
    Last Post: 2008-06-18, 02:17 AM
  4. Replies: 4
    Last Post: 2008-04-17, 01:15 PM
  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
  •