Autopopulate other fields based on QuickSearch result

sugarcrmdevelopers —  June 20, 2012 — 14 Comments

We get a lot of great questions in the forums, and some even better answers :-). Here’s question we had recently…

I have an editview with a relationship field on it. When a selection is made, I need a value from the related record to populate another text/number field on the editview.

I have tried implementing field_to_name_array in the relationship field’s displayParams, but that only seems to work when the relationship field is populated from the search popup. I need it to populate once a quicksearch result is selected.

Any thoughts?

I can’t tell you how many people have been struggling with this sort of thing, as the popup and quicksearch use different configurations to do this. Fortunately, Jeff Bickart, a prolific community member and CTO at Sugar Gold Partner NEPO Systems, stepped in with this great answer…

This is a bit trickier: what you need to do is update the vardef using an Extension


$dictionary["MODULE"]["fields"]["FIELD"]["populate_list"] = array(
        "name","id", "opportunity_num",

$dictionary["MODULE"]["fields"]["FIELD"]["field_list"] = array(
  "opportunities_name","opportunities_id", "parent_opp_no"),

They way that it works is that populate_list contains all the fields that you want to copy from the relate module. the field_list is the list of fields on the screen.

Thanks Jeff for jumping in with the great answer to the poster’s issue!

14 responses to Autopopulate other fields based on QuickSearch result


    Does fields_list also affect the results returned by the Popup Window on relate fields like this? I want to say those are held separately, in the editview metadata?


       Hi Matthew, seems the SQS customization is not done through metadata files but directly in vardef’s extension files.

      As John said : the popup and quicksearch use different configurations

      If my memory is good, popup’s customizations can be done using metadata (as described in the post using displayparam / field_to_name), but for SQS, developper must use the vardef’s extension (no metadata property exist)


         Hi Matthew,
        The above field_to_name_array didn’t work for me.

        I want to get populate Accounts module from custom module
        In my Accounts module I have one relate field named as division_c this relate field fetch me to the custom module where one externalid_c and one dropdown named grading_c is there. These fields are also in the Accounts module. But I want to populate these grading_c and externalid_c field in the Accounts module taking data from the custom module. I used above code like as,

        array (
                    ‘name’ => ‘division_c’,
                    ‘studio’ => ‘visible’,
                    ‘label’ => ‘LBL_DIVISION’,
                    ‘displayParams’ => array (
                        ‘field_to_name_array’ => array(
                            ‘id’=>’d_division_id_c’,                      //hidden id
                            ‘name’=>’d_division_id_c’,                //hidden name
                            ‘division_c’ => ‘name’,                      //division_c field is in accounts module and name is in the custom module
                      ‘additionalFields’ => array(
                              ‘grading_c’ => ‘grading_c’,


    Thanks for sharing with us, John and Jeff !
    It should definitively be part of Developper application guide, with the popup window customization too !


    An important note here : if your relate module is on the accounts, it will not work, accounts SQS arrays are written within the code and extension will not be taken into account by SugarCRM.

    With relate fields on custom module’s, this works like a charm !
    So this seems that due to QuickSearchDefaultscode integratd in SugarCRM, the trick given will only work on certain modules.

    If other developers can confirm this behavior, maybe we will fill a bug report to ask a fix in next release ?


    I like Your Article very much About SugarCRM Development. and this Info is very Informative and most useful for me. Thanks for share this valuable Information.


    After doing some additional research, it is not possible to use this technique for Campaigns, Teams, Users, Contacts, or Accounts their QuickSearch is predefined in QuickSearchDefaults.php which is not extendable


      So let me get this straight; it’s not possible to autopopulate fields in a module that is linked to Contacts?


        Not exactly… it just has to be done in a different way… A little bit of JavaScript is needed for adding additional field_list and populate_list for QuickSearch for the modules mentioned above. I am logging a feature request to resolve the issue in a future release



    I tried to populate the accounts module some of the fields while selecting the relate field, relate field(division_c).
    Accounts module fields are
    “ownership”,”grading_c”, “prospectsubscriptionstatus_c”,”externalid_c”,

    Related module fields are


    how would I autofill the fields present in the accounts module by related module d_Division.

    Thanks & Regards
    Sumit Sahay


    Including custom fields in populate list is not working. Can you please help on this ?

    $dictionary[“MODULE”][“fields”][“FIELD”][“populate_list”] = array(
    “name”,”id”, “opportunity_num”,

    $dictionary[“MODULE”][“fields”][“FIELD”][“field_list”] = array(
    “opportunities_name”,”opportunities_id”, “parent_opp_no”),

Trackbacks and Pingbacks:

  1. Autofil some fileds in the accounts module while selecting the relate field. - July 10, 2012

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s