AnsweredAssumed Answered

How to set a value of dropdown based on parent dropdown.

Question asked by Lokesh Bhandari on Mar 13, 2019
Latest reply on Mar 14, 2019 by André Lopes

Hello,

 

I want to set value in dropdown from parent dropdown. Based on selection of company I need to show group lists from database. If company name is changed then group name should be get from currently selected company. 

 

SugarCRM Version : 7.9.0.0

 

Below is my code

 

({
extendsFrom: 'CreateView',
initialize: function (options) {
this.model.on("change:tally_company_name",this.selectgroupbaseoncompany, this);
this._super('initialize',[options]);
this.on('render', this.selectgroupbaseoncompany, this);
},

selectgroupbaseoncompany:function()
{
var tally_company_name = this.model.get('tally_company_name');
var self = this;
$.ajax(
{
url: 'rest/v10/TallyConnector/GetTallyGroupNameByCompanyName/'+tally_company_name,
type: 'POST',
success: function(get_body)
{
var dd_values = [];
_.each(get_body, function(value, key) {
console.log(key, value);
dd_values[key] = value;
});
this.model.fields['tally_group'].options = dd_values; // set data to list element
this.render();
}
});

},
})

 

But it show me error Uncaught TypeError: Cannot read property 'fields' of undefined at

Outcomes