Results 1 to 7 of 7

Thread: Search field within custom module

  1. #1
    almafer is offline Junior Member
    Join Date
    Jul 2008
    Posts
    4

    Default Search field within custom module

    Hi, I have created a new module, with a relate to account name, and a subpanel showing in standard account module. Is it possible to search within the account module only those with custom fields from the custom module?

  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: Search field within custom module

    Hi, almafer

    Can you explain your needs again?

    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
    almafer is offline Junior Member
    Join Date
    Jul 2008
    Posts
    4

    Default Re: Search field within custom module

    Of course!
    I have made a custom module (with module creator built in sugar 5.00f), regarding some kind of products. It works, and I have also a subpanel linked to standard Sugar account module. Well, my question is: how can I do a search (in module account) with a specific product; I want to view all the accounts which have a specific product (in order to do campaign etc).
    Thanks!!!
    Almafer

  4. #4
    almafer is offline Junior Member
    Join Date
    Jul 2008
    Posts
    4

    Default Re: Search field within custom module

    Any advice? Please help!

  5. #5
    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: Search field within custom module

    Hi, Almafer.

    Bellow are the steps and tricks:

    You have to create an extended vardefs for the Accounts module including or modifying the field which defines the Product module. In the code bellow I added the related field Account into a custom module and this field is available into Basic Search of the Custom module. You will apply the equivalent for Accounts module.

    PHP Code:
      'account_name' => 
      array (
        
    'required' => '1',
        
    'source' => 'non-db',
        
    'name' => 'account_name',
        
    'rname' => 'name',
        
    'vname' => 'LBL_ACCOUNT_NAME',
        
    'type' => 'relate',
        
    'massupdate' => 0,
        
    'comments' => '',
        
    'help' => '',
        
    'duplicate_merge' => 'disabled',
        
    'duplicate_merge_dom_value' => 0,
        
    'audited' => 0,
        
    'reportable' => 0,
        
    'len' => '255',
        
    'id_name' => 'account_id',
        
    'module' => 'Accounts',
        
    'studio' => 'visible',
        
    'link' => 'account_link',
      ),
        
    'account_link' => 
        array (
          
    'name' => 'account_link',
          
    'type' => 'link',
          
    'relationship' => 'lgs_suport_accounts',
          
    'vname' => 'LBL_ACCOUNT_NAME',
          
    'link_type' => 'one',
          
    'module' => 'Accounts',
          
    'bean_name' => 'Account',
          
    'source' => 'non-db',
        ), 
    This piece of code defines the relationship between the default Account module and the custom module related to Accounts.

    PHP Code:
        'lgs_suport_accounts' => 
        array (
          
    'lhs_module' => 'Accounts',
          
    'lhs_table' => 'accounts',
          
    'lhs_key' => 'id',
          
    'rhs_module' => 'lgs_Suport',
          
    'rhs_table' => 'lgs_suport',
          
    'rhs_key' => 'account_id',
          
    'relationship_type' => 'one-to-many',
        ), 
    There is a bug into data/SugarBean.php which cause a sql error in some situation.
    You can fix it modifying the line

    PHP Code:
                        $where preg_replace('/(^|\s)' $join_table_name '\./''${1}' $params['join_table_alias'] . '.'$where); 
    For this one

    PHP Code:
                        $where preg_replace('/(^|\s?)' $join_table_name '\./''${1}' $params['join_table_alias'] . '.'$where); 
    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.

  6. #6
    tomatosld is offline Member
    Join Date
    Jul 2008
    Posts
    5

    Default Re: Search field within custom module

    Aha! I think you are on to the solution I need as well. Although I am trying to do something a little different..

    I am trying to add a custom relate field from Leads to a custom module to the Mass Update subpanel.

    I have added the following to define the fields in the vardefs of Leads to set massupdate to true, but I was doing it with true, not 1... Does that make a difference? It's still not working. Please help me figure out what I've got wrong here:

    PHP Code:
       'assigned_team_id' =>
      array (
        
    'name' => 'assigned_team_id_c',
        
    'rname' => 'name',
        
    'id_name' => 'teams_teams_id_c',
        
    'vname' => 'LBL_ASSIGNED_TEAM',
        
    'type' => 'relate',
        
    'link'=>'assigned_team_link',
        
    'table' => 'teams_teams',
        
    'isnull' => 'true',
        
    'module' => 'teams_teams',
        
    'dbType' => 'varchar',
        
    'len' => 'id',
        
    'source'=>'custom_fields',
        
    'reportable'=>false,
        
    'massupdate'=> 1,
      ),

        
    'assigned_team_link' =>
      array (
        
    'name' => 'assigned_team_link',
        
    'type' => 'link',
        
    'relationship' => 'leads_assigned_team',
        
    'link_type'=>'one',
        
    'side'=>'right',
        
    'source'=>'custom_fields',
        
    'vname'=>'LBL_ASSIGNED_TEAM',
      ), 
    I have changed the source from 'non-db' to 'custom_fields', as I read in this forum somewhere that was a change for defining custom fields 5.0.0x (I'm f right now, I know I need to upgrade to g, but let's get this working first...)

    I have also defined the relationship like this: (again in vardef on Leads - should this be on the custom module 's vardef instead, since it goes the other way?)
    PHP Code:
    ,'lead_assigned_team'=> array(
                                        
    'lhs_module'        =>     'teams_teams'
                                        
    'lhs_table'            =>     'teams_teams'
                                        
    'lhs_key'             =>     'id',
                                        
    'rhs_module'        =>     'Leads'
                                        
    'rhs_table'            =>     'leads_cstm'
                                        
    'rhs_key'             =>     'teams_teams_id_c',
                                        
    'relationship_type'    =>    'one-to-many'
                                    

    I also found a relationship table in the sql and have added this relationship there as well. But still the field does not appear in Mass Update.

    Finally, let me say this: what I'd really like to do is be able to import info to this custom relate field right from the beginning. I've been able to map data to the field in the import (as I do with assigned user id) but the data doesn't stick. I believe these two issues are the same. I simply need to define the relationship between Leads and my custom module in the right place.

    Thanks in advance for helping with my code!
    Last edited by tomatosld; 2008-08-03 at 07:20 PM.

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

    Default Re: Search field within custom module

    Thanks alot andopes. I can finally search on account name in my custom module.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. relate field search problem in custom module
    By mikesolomon in forum Help
    Replies: 12
    Last Post: 2009-07-11, 03:27 PM
  2. Replies: 0
    Last Post: 2007-01-16, 05:27 PM
  3. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  4. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM

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
  •