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
  • Hi Matthew,

    I checked the console, the field is send ('test_my_select_c'), but is empty.
    This is because when the data is submitted, it cannot resolve the "new" keys
    in the original list. If I change the keys in the example to keys that exist
    in the list that is connected to the multi-select dropdown, then those keys
    are submitted. So the next idea was to change the values of the list, but
    there is no app.lang.setAppListStrings

    So now I created a new list (in Studio) coded like this:

    item0 => item0
    item1 => item1
    ...

    And connected the multi-dropdown to that list. So when I retrieve the list of
    items from a remote source, I replace the values in the multi-dropdown, and
    in the before save hook I see what items have been selected, because I have
    the list from the remote source there to.

    Thanks,
    Michiel

Reply
  • Hi Matthew,

    I checked the console, the field is send ('test_my_select_c'), but is empty.
    This is because when the data is submitted, it cannot resolve the "new" keys
    in the original list. If I change the keys in the example to keys that exist
    in the list that is connected to the multi-select dropdown, then those keys
    are submitted. So the next idea was to change the values of the list, but
    there is no app.lang.setAppListStrings

    So now I created a new list (in Studio) coded like this:

    item0 => item0
    item1 => item1
    ...

    And connected the multi-dropdown to that list. So when I retrieve the list of
    items from a remote source, I replace the values in the multi-dropdown, and
    in the before save hook I see what items have been selected, because I have
    the list from the remote source there to.

    Thanks,
    Michiel

Children