AnsweredAssumed Answered

Alter multiselect dropdown values dynamically

Question asked by michielvaningen on Aug 28, 2015
Latest reply on Jun 12, 2017 by Francesca Shiekh
Hi all,

I'm using SugarCRM 7.6, and still learning every day. I have created a multiselect dropdown in a custom module using studio. I also created a dropdown list that is used by the multiselect dropdown. If I create a new record, choose some values and save the data, I can see the data is in the bean (before save hook, field "test_my_select_c" has the values I selected).

Now I want to load the options in the multiselect dropdown  dynamically from a remote source. To do this I have created a enum.js file in with the follwing contents:

({
    extendsFrom: 'EnumField',

    initialize: function (options) {
        this._super('initialize', [options]);
    },

    _render: function () {
        if (this.name == '"test_my_select_c') {
            if (_.isEmpty(this.items)) {
                this.setItems();
                return;
            }
        }
        this._super('_render');
    },

    setItems: function () {
        this.items = {"key1": "value1","key2": "value2","key3": "value3" };
        this._render();
    }
})

When I create a new record, I see the new options in the multiselect dropdown,
I can select them, and I can save the record. The thing that is not yet working,
is that I don't see the values in the before save hook, like the values are
not submitted. What am I missing here?

Thanks for any help!

Best regards,
Michiel

Outcomes