can we set new values dynamically in multi select in SugarCRM?

17 views Asked by At

can we set new 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' }

            ];

            dummyOptions.forEach(function (option) {
                var optionElement = $('<option>').val(option.value).text(option.label);
                dropdownElement.append(optionElement);
            });
}}

But this is not working ,it is not retrieving $el values or select element inside it . I also tried to set in afterretrieve Hook : -


        //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^';
0

There are 0 answers