AnsweredAssumed Answered

Dropdown field shows all the values

Question asked by Varun Nath A V on Jan 31, 2016
Latest reply on Feb 1, 2016 by meveridge

I have a custom muliselect field say "product_custom_field_c" in Products module and a drop-down field "case_custom_field_c" in Cases module. Also there is a relate field for Products module in Cases. On the on-change event for this Product field, I need to populate the option  values for the field "case_custom_field_c" from the selected Product''s "product_custom_field_c" field.

 

I have created the custom drop-down field "case_custom_field_c"  for Cases module as explained below.

 

({

    extendsFrom: 'EnumField',

 

    initialize: function (options) {

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

        this.type = 'enum';

        this.model.on("change:{related_module_id}",this.loadValues, this);

    },

 

    loadValues: function() {

        // clear the list

        this.items = null;

        this.render();

    },

    /**

     * Load the options for this field and pass them to callback function.  May be asynchronous.

     * @param {Boolean} fetch (optional) Force use of Enum API to load options.

     * @param {Function} callback (optional) Called when enum options are available.

     */

    loadEnumOptions: function(fetch, callback) {

        this.isFetchingOptions = true;

        var self = this;

        if (this.model.get{related_module_id})) {

          var options = {};

        // Added API call to load options from related module

      options[key] = value;

       self.items = options;

       callback.call(self);

}                

})

 

This loads related options for the on-change event. But after saving the record and then check the custom field, it shows all the fields from the "options" parameter defined in the vardef for this field. I need to show only the values related to the selected Product and not all the values.

 

I am using sugarCRM 7.6. Does anyone came across this issue?

Outcomes