Alter multiselect dropdown values dynamically

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
Parents
  • I'd say the first thing you should do is verify that they are not being sent properly, as you suspect.  Check your browser console and inspect the HTTP request that gets sent when you click "Save".  Does 'test_my_select_c' have the expected value?

    Is it only a problem with multi-select dropdown or does it happen with regular dropdowns as well?

    App Ecosystem @ SugarCRM

Reply
  • I'd say the first thing you should do is verify that they are not being sent properly, as you suspect.  Check your browser console and inspect the HTTP request that gets sent when you click "Save".  Does 'test_my_select_c' have the expected value?

    Is it only a problem with multi-select dropdown or does it happen with regular dropdowns as well?

    App Ecosystem @ SugarCRM

Children
No Data