AnsweredAssumed Answered

How can I popupate a dropdown list from a table.

Question asked by delsugar on Mar 11, 2016
Latest reply on Dec 12, 2017 by Francesca Shiekh

Hello

 

VERSION 7.6.x PROFESSIONAL

 

Can someone provide an example as to how to populate a dropdown list from a table. The example from sugar does not appear to work for me.

 

Ideally I would like to populate a dropdown from a table but I am trying to just implement the following sample code from sugar at exactly as is and it does not work.
I see my code loop though in sugarlog but nothing gets update.

https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.5/Language_Framework/Managing_Lists/

 

<?php

require_once('modules/Studio/DropDowns/DropDownHelper.php');

private function syncDropdown($dropdown)

    {

        $parameters = array();

        $parameters['dropdown_name'] = 'my_list';

        $listValues = array(

        'Key_Value_1' => 'Display Value 1',

        'Key_Value_2' => 'Display Value 2',

        'Key_Value_3' => 'Display Value 3'

        );

        $count = 0;

        foreach ($listValues as $key=>$value)

        {

            $parameters['slot_'. $count] = $count;

            $parameters['key_'. $count] = $key;

            $parameters['value_'. $count] = $value;

            //set 'use_push' to true to update/add values while keeping old values

            $parameters['use_push'] = true;

            $count++;

            $GLOBALS['log']->security('dropdown='.$dropdown['name'].' value='.$value);

        }

}
}

Outcomes