can we set values dynamically in multi select in SugarCRM ?

can we set values dynamically in multi select in SugarCRM ?

i am trying to set values like this : -

    initialize: function (options) {

        this._super('initialize', [options]);

        this.model.on('sync', _.bind(this.bindCustomMultiSelectDropdown, this));

    },

    bindCustomMultiSelectDropdown: function () {

        var fieldName = 'employee_name2_c';

        var dropdownElement = this.getField(fieldName).$el.find('select');

        if (dropdownElement) {

            dropdownElement.empty();

            var dummyOptions = [

                { value: 'dummy1', label: 'Dummy Option 1' },

                { value: 'dummy2', label: 'Dummy Option 2' },

                { value: 'dummy3', label: 'Dummy Option 3' }

            ];

            console.log('dropdownElement', dropdownElement);

            dummyOptions.forEach(function (option) {

                var optionElement = $('<option>').val(option.value).text(option.label);

                dropdownElement.append(optionElement);

            });
}}

But this is not working , I also tried to set in afterretrieve Hook : -

//1.  $bean->field_defs['emp_name1_c']['options'] = [

        //     ['value' => 'dummy1', 'label' => 'Dummy Option 1'],

        //     ['value' => 'dummy2', 'label' => 'Dummy Option 2'],

        //      ]; -- not working

        //2. $bean->field_defs['emp_name1_c']['options'] = '^Aaron^,^Amanda^'; -- not working

        //3   $bean->field_defs['emp_name1_c']['options'] = 'dummy1,dummy2'; -- not working

        // $optionsData = ['dummy1', 'dummy2'];

        // $optionsString = implode(',', $optionsData);

        // $bean->field_defs['emp_name1_c']['options'] = $optionsString; -- not working

        $bean->emp_name1_c = '^Aaron^,^Amanda^';

Parents Reply Children
No Data