Results 1 to 4 of 4

Thread: 5.0c (or d) - One-to-Many Relationship problems

  1. #1
    jim.thornton is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    257

    Default 5.0c (or d) - One-to-Many Relationship problems

    Okay... I followed the wiki that was suggested to me (but I didn't do the last step "Code Changes" because it said if using 5.0b then it has already been fixed. Please tell me if this is wrong.

    I've added a custom module that will be used to track addresses so that I can have a history of addresses for the client. I have a field where I can set it to Current or Previous.

    When in the client details view, I scroll down and will see the subpanel. I can click on Create and it will go to the edit view of the new module and I can add an address. The problem is that when I click on the "Create" button, I want it to pre-populate two fields. The first is the "Client Name" of where I just came from (so I don't have to manually do it), and then I would like it to pre-populate the "Date-Modified" field with the current date.

    Can somone pleaes tell me how to do this?

    I have attached s a screenshot of the subpanel and the edit view... I forgot to mention that the layout does't look right (the fields in the subpanel are suppose to be 10, 30,10,10,15,15,5,4 % width) and it looks like they aren't.
    ________
    WetLana
    Attached Images Attached Images   
    Last edited by jim.thornton; 2011-09-08 at 04:23 AM.

  2. #2
    dlorenzetti's Avatar
    dlorenzetti is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    São Paulo, Brasil
    Posts
    189

    Default Re: 5.0c (or d) - One-to-Many Relationship problems

    Hi Jim,

    For get the Client Name field in EditView you can put a code in your Custom Module Module:

    In modules/<NAME_OF_MODULE>/views/view.edit.php

    PHP Code:
    <?php

    require_once('include/MVC/View/views/view.edit.php');

    class 
    NAME_OF_MODULEViewEdit extends ViewEdit{

        function 
    NAME_OF_MODULEViewEdit() {
             
    parent::SugarView();
        }

         function 
    display(){
            
    $this->ev->process();

            if (empty(
    $this->ev->focus->id) && isset($_REQUEST['parent_type']) && ($_REQUEST['parent_type'] == 'Client' && isset($_REQUEST['parent_name']) && isset($_REQUEST['parent_id']))) {
                
    $this->ev->fieldDefs['client_name']['value'] = $_REQUEST['parent_name'];
                
    $this->ev->fieldDefs['client_id']['value'] = $_REQUEST['parent_id'];
            }

            echo 
    $this->ev->display();
         }
    }
    ?>

    And the width take a look in /modules/<NAME_OF_MODULE>/metadata/subpanels/default.php
    Diego Lorenzetti
    Lampada Global Services - Open Source Solutions
    Phone: +55 11 3237-3110
    Email: equipe@lampadaglobal.com
    Site: www.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.

  3. #3
    jim.thornton is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    257

    Default Re: 5.0c (or d) - One-to-Many Relationship problems

    Quote Originally Posted by dlorenzetti
    Hi Jim,

    For get the Client Name field in EditView you can put a code in your Custom Module Module:

    In modules/<NAME_OF_MODULE>/views/view.edit.php

    PHP Code:
    <?php

    require_once('include/MVC/View/views/view.edit.php');

    class 
    NAME_OF_MODULEViewEdit extends ViewEdit{

        function 
    NAME_OF_MODULEViewEdit() {
             
    parent::SugarView();
        }

         function 
    display(){
            
    $this->ev->process();

            if (empty(
    $this->ev->focus->id) && isset($_REQUEST['parent_type']) && ($_REQUEST['parent_type'] == 'Client' && isset($_REQUEST['parent_name']) && isset($_REQUEST['parent_id']))) {
                
    $this->ev->fieldDefs['client_name']['value'] = $_REQUEST['parent_name'];
                
    $this->ev->fieldDefs['client_id']['value'] = $_REQUEST['parent_id'];
            }

            echo 
    $this->ev->display();
         }
    }
    ?>

    And the width take a look in /modules/<NAME_OF_MODULE>/metadata/subpanels/default.php
    where you have typed $_REQUEST['parent_name'] and $_REQUEST['parent_type']

    Should I change those parent_ values or should I leave it exactly as is?
    ________
    MilenaHot
    Last edited by jim.thornton; 2011-09-08 at 04:24 AM.

  4. #4
    dlorenzetti's Avatar
    dlorenzetti is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    São Paulo, Brasil
    Posts
    189

    Default Re: 5.0c (or d) - One-to-Many Relationship problems

    This values comes for default, when you click for new address the sugar go to address page, and pass for $_GET the "parent_name" that is the name of your parent module (Client in this case) and parent_id (Client's id).

    You can leave parent_values exacty as it. But you need to see the name of your fields (client_id and client_name) and change it if necessary.
    Diego Lorenzetti
    Lampada Global Services - Open Source Solutions
    Phone: +55 11 3237-3110
    Email: equipe@lampadaglobal.com
    Site: www.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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. upgraded to 4.5.1e, received "Metadata for table tracker does not exist"
    By sfgeorge in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2007-09-03, 02:24 PM
  2. problemi step 6 di SugarSuite-Full-4.0.1h
    By lucia in forum Italiano
    Replies: 0
    Last Post: 2006-12-27, 08:50 AM
  3. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM
  4. Replies: 7
    Last Post: 2006-06-06, 07:56 PM
  5. 4.0.1 Installation Problem
    By clawton in forum Help
    Replies: 14
    Last Post: 2006-02-13, 04:17 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
  •