Results 1 to 7 of 7

Thread: custom dropdown based on query

  1. #1
    jeffreyvsmith is offline Sugar Community Member
    Join Date
    Oct 2005
    Posts
    72

    Default custom dropdown based on query

    Wanting to create a dropdown that contains the results of a sql query. For example, I want a dropdown of users that just selects usernames that are in the database or select contacts that are in the database. Will this work or does the content of a dropdown have to be text in the en_us.lang.php file?

    If a sql query cannot be used, what can I use to auto update the php file? Is this a job for sed/awk/cron or something. Any thoughts?

    SugarCRM 4.0.0
    PHP 5.1.6
    MySQL 5.0.27
    FC6 2.6.22.4-45.fc6

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: custom dropdown based on query

    Why not use the select boxes that are used to assign a user to a record on the detail pages? There are contact ones as well. It would take some custom coding to do however. Or are you trying to associate more than one user with a record? Would need to use subpanels then.

  3. #3
    mabechard is offline Junior Member
    Join Date
    Nov 2007
    Posts
    4

    Default Re: custom dropdown based on query

    Hi,

    If I must have a dropdown because we want that into ours interface (you know designer...) ? How should I do? I need to fill a dropdown from a “mysql” table with id,value I try to modified the “enum” box type …. But it doesn’t work.

    Marc-Andre Giroux

  4. #4
    JeanetteRoss is offline Sugar Community Member
    Join Date
    Apr 2007
    Posts
    61

    Default Re: custom dropdown based on query

    I am interested in this too.
    What a drop down or select box based on a previous field entry/select box
    i.e.
    Tasks
    Pick Related to accounts - pick account
    Pick Contact only belonging to the account picked

  5. #5
    mabechard is offline Junior Member
    Join Date
    Nov 2007
    Posts
    4

    Default Re: custom dropdown based on query

    This is my solution in sugar code :

    #1 : Change vardefs.php

    'support_term' =>
    array (
    'name' => 'support_term',
    'vname' => 'LBL_SUPPORT_TERM',
    'type' => 'varchar',
    'len' => '25',
    'function'=>array('name'=>'getSupportTerms', 'returns'=>'html', 'include'=>'modules/ProductTemplates/ProductTemplate.php'),
    'comment' => 'Term (length) of support contract'
    ),

    then add the function :

    function getSupportTerms($focus, $field='support_term', $value,$view='DetailView') {
    if($view == 'EditView') {
    $html = "<select id=\"$field\" name=\"$field\">";
    global $app_list_strings;
    $the_term_dom = $app_list_strings['support_term_dom'];
    array_unshift($the_term_dom,'');
    $html .= get_select_options_with_id($the_term_dom,$focus->support_term);
    $html .= "</select>";
    return $html;
    }

    return $focus->support_term;
    }

    then add the fields on all files needed for the UI

    then modifie this code :

    function getMyDropDown($focus, $field='myproduct', $value,$view='DetailView') {
    if($view == 'EditView') {
    $html = "<select id=\"$field\" name=\"$field\">";
    $html = get_mysql_value($focus->support_term)
    $html .= "</select>";
    return $html; //return my dropdown
    }

    return $focus->myproduct; //return view value
    }

    change :

    'myproduct' =>
    array (
    'name' => 'myproduct',
    'vname' => 'LBL_PRODUCT',
    'type' => 'varchar',
    'len' => '25',
    'function'=>array('name'=>getMyDropDown, 'returns'=>'html', 'include'=>'modules/mymodule/mymodules.php'),
    'comment' => 'My Product',
    ),
    Last edited by mabechard; 2007-11-07 at 09:01 PM.

  6. #6
    mabechard is offline Junior Member
    Join Date
    Nov 2007
    Posts
    4

    Default Re: custom dropdown based on query

    I forgot to add the javascript :

    $html = "<select id=\"$field\" name=\"$field\" onchange=\"DoSomeCode()\">";

  7. #7
    Momin is offline Junior Member
    Join Date
    Apr 2008
    Posts
    2

    Default Re: custom dropdown based on query

    Hi, i have been working to create a dynamic dropdown as alike as told in the above lines. em a very new to sugar.
    Can you guide me a bit more on this? also if you could refer me some place, books, articles which can be helpful in development.

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. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM
  3. Replies: 7
    Last Post: 2006-06-06, 07:56 PM
  4. Contact Search Form - Custom Dropdown Field
    By aram in forum General Discussion
    Replies: 2
    Last Post: 2005-05-01, 03:57 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
  •