Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: relate field search problem in custom module

  1. #1
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default relate field search problem in custom module

    I have built a custom module and added a relate field account

    When added to the edit view I get and input box to add the account plus a select & clear button as I wanted

    If I add the account name using the select button it all works perfectly but if I type in the account name it fails

    Also typing in the first few letters of the account name does not give me a dropdown like I normally get on select field

    Can someone explain to me what I am doing wrong - Thanks

  2. #2
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: relate field search problem in custom module

    Quoting the wiki:
    Relate
    The Relate field combines a blend of a text field with code to allow quicksearch. The quicksearch code is generated for EditViews (see include/TemplateHandler/TemplateHandler.php). There are also buttons to invoke popups and a button to clear the value. For DetailViews, the Relate field creates a hyperlink that will bring up a DetailView request for the field's value.


    Within the metadata file, the Relate field can be rendered with the snippet:
    Code:
      
    array (
    	array('name'=>'account_name',
    		  'type'=>'relate',
    		  'displayParams'=>array('allowNewValue'=>true)
    		 ),
    	   ),
    This will create a relate field that allows the user to input a value not found in the quicksearch list.

    name

    Standard name definition when Metadata definition is defined as an Array

    displayParams

    • required (optional) - Marks the field as required and applies clients side validation to ensure value is present when save operation is invoked from EditView.
    • readOnly (optional for editviewdefs.php file only) - Makes the text field input area readonly so that you have to just use the popup selection.
    • popupData - This field is generated for you by default. See include/SugarFields/Fields/SugarFieldRelate.php for more information. You should not need to override this setting.
    • allowNewValue (optional for editviewdefs.php file only) - This setting allows the user to specify a value that is not found from the quicksearch list of results.


    End of quoting.
    You can find it here:
    http://www.sugarcrm.com/wiki/index.p...rField_Widgets
    What do you think the cookie monster eats ?

  3. #3
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: relate field search problem in custom module

    Thanks for this

    I managed to get it working

    Changed the modules vardefs.php to include

    'account_name' =>
    array (
    'name' => 'account_name',
    'rname' => 'name',
    'id_name' => 'account_id',
    'vname' => 'LBL_ACCOUNT_NAME',
    'type' => 'relate',
    'link'=>'accounts',
    'table' => 'accounts',
    'join_name'=>'accounts',
    'isnull' => 'true',
    'module' => 'Accounts',
    'dbType' => 'varchar',
    'len' => 100,
    'source'=>'non-db',
    'unified_search' => true,
    'comment' => 'The name of the account represented by the account_id field',
    'required' => true,
    ),

    and changed account to account_name in editviewdefs.php and now it works properly

    Thanks again

  4. #4
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: relate field search problem in custom module

    A related problem

    I need to be able to search by the account on my custom module

    I managed to add the' account name' to the advanced search but although the select button appears and you can get the popup with account names which populates the field when you press search nothing is returned

    Any help would be appreciated

  5. #5
    sidh211 is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    126

    Default Re: relate field search problem in custom module

    hello everyone

    i am also facing the same problem i want on custom relate field in account module i mangaed to do that using studio and exposed it in all 3 views as well as in basic search but when i try to search using that custom fild it gives an error
    sql error invalid clumn name user_name_c

    plss help me out thanks

    reds
    sid

  6. #6
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: relate field search problem in custom module

    Quote Originally Posted by mikesolomon
    A related problem

    I need to be able to search by the account on my custom module

    I managed to add the' account name' to the advanced search but although the select button appears and you can get the popup with account names which populates the field when you press search nothing is returned

    Any help would be appreciated
    Hi Mike,
    sorry for posting so late...
    I think the cause of this problem is that you changed name from account to account_name.
    Anyway I hope you've already managed to fix it...
    What do you think the cookie monster eats ?

  7. #7
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: relate field search problem in custom module

    Quote Originally Posted by sidh211
    hello everyone

    i am also facing the same problem i want on custom relate field in account module i mangaed to do that using studio and exposed it in all 3 views as well as in basic search but when i try to search using that custom fild it gives an error
    sql error invalid clumn name user_name_c

    plss help me out thanks

    reds
    sid
    Hi sid,
    it looks like it doesn't like your custom field's name.
    Actually it could be what's causing that error, since there's a field with that name already, and it's pk for Users.
    Try with a different name...
    What do you think the cookie monster eats ?

  8. #8
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: relate field search problem in custom module

    Quote Originally Posted by DragonflyMaster
    Hi sid,
    it looks like it doesn't like your custom field's name.
    Actually it could be what's causing that error, since there's a field with that name already, and it's pk for Users.
    Try with a different name...

    see http://www.sugarcrm.com/forums/showt...146#post111146 for solution

  9. #9
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: relate field search problem in custom module

    Quote Originally Posted by mikesolomon
    Thanks Mike,
    interesting link...
    What do you think the cookie monster eats ?

  10. #10
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: relate field search problem in custom module

    Quote Originally Posted by DragonflyMaster
    Thanks Mike,
    interesting link...

    It actually means that the wiki on creating a one-many relationship is incorrect

    You are better off creating the relate fields in module builder not studio

    If they are created in module builder they can be searched on - if created in studio you can't

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Custom Field add not visible is Edit Layout
    By tylerpoint in forum Help
    Replies: 0
    Last Post: 2007-07-09, 05:56 AM
  2. Replies: 0
    Last Post: 2006-07-22, 06:53 PM
  3. Replies: 2
    Last Post: 2006-06-13, 09:42 AM
  4. Replies: 7
    Last Post: 2006-06-06, 07:56 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
  •