Results 1 to 3 of 3

Thread: How to display related field?

  1. #1
    asbaeza is offline Sugar Community Member
    Join Date
    Feb 2006
    Location
    Mexico
    Posts
    16

    Question How to display related field?

    Hi.

    I am using some custom fields related to other tables. For example, one of them is related to accounts id (a customized id indeed) . I can select or type this field, but do not know how to display the account name, as a way to validate I am using the right desired value (so reducing wrong typing possibilities).

    Does anyone know hot to achieve this?

  2. #2
    lion is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: How to display related field?

    you can either retrieve the name in php code (probably in a fill_in_additional* function) and display the result or you can do something like this (this works in the listview and should also work in the detailview):

    PHP Code:
      'account_id' => 
      array (
        
    'required' => false,
        
    'name' => 'account_id',
        
    'vname' => '',
        
    'type' => 'id',
        
    'massupdate' => 0,
        
    'comments' => '',
        
    'help' => '',
        
    'duplicate_merge' => 'disabled',
        
    'duplicate_merge_dom_value' => 0,
        
    'audited' => 0,
        
    'reportable' => 0,
        
    'len' => 36,
      ),
      
    'account' => 
      array (
        
    'required' => true,
        
    'source' => 'non-db',
        
    'name' => 'account',
        
    'vname' => 'LBL_ACCOUNT',
        
    'type' => 'relate',
        
    'massupdate' => 1,
        
    'comments' => '',
        
    'help' => '',
        
    'duplicate_merge' => 'disabled',
        
    'duplicate_merge_dom_value' => '0',
        
    'audited' => 0,
        
    'reportable' => 0,
        
    'len' => '255',
        
    'id_name' => 'account_id',
        
    'ext2' => 'Accounts',
        
    'module' => 'Accounts',
        
    'quicksearch' => 'enabled',
        
    'studio' => 'visible',
        
    'rname' => 'name',
        
    'link' => 'account_link',
      ),
        
    'account_link' => 
        array (
          
    'name' => 'account_link',
          
    'type' => 'link',
          
    'relationship' => 'account_search',
          
    'vname' => 'LBL_ACCOUNT',
          
    'link_type' => 'one',
          
    'module' => 'Accounts',
          
    'bean_name' => 'Account',
          
    'source' => 'non-db',
        ), 
    along with the relationship:
    PHP Code:
        'relationships'=>array (
     
    'account_search' => 
        array (
          
    'lhs_module' => 'Accounts',
          
    'lhs_table' => 'accounts',
          
    'lhs_key' => 'id',
          
    'rhs_module' => 'oqc_ExternalContract',
          
    'rhs_table' => 'oqc_externalcontract',
          
    'rhs_key' => 'account_id',
          
    'relationship_type' => 'one-to-many',
        ),  
    ), 

  3. #3
    bhawin13 is offline Sugar Community Member
    Join Date
    Apr 2006
    Posts
    45

    Default Re: How to display related field?

    lion,

    Thanks for good useful post.
    It has helped me to solve my problem.

    I would like to add more thing that at some place, where field of type= relate, metadata information of link is (for ex: 'link' => 'account_link') is missed but it is really important to show field value in list view, specially if field is not like account_name, project name. If you want to show project start date of project in list view of any other related module of project then 'link' attribute is important.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Add user related custom field
    By kuske in forum Developer Help
    Replies: 14
    Last Post: 2011-02-08, 06:17 AM
  2. how to make a related field read only
    By uou in forum Developer Help
    Replies: 3
    Last Post: 2008-08-06, 06:35 AM
  3. Replies: 0
    Last Post: 2008-07-02, 08:50 AM
  4. Replies: 1
    Last Post: 2008-06-11, 04:32 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
  •