I have created another entity - Special Rate Card same as Product.
My Account has an option - either discount or rate card.
In quotes if the selected account has discount then quote item will load values from Product. And if it has rate card, quote item will load from Special rate card.
I have an enum field serviceDescription which loads description accordingly.
Espo.define('Advanced:Views.QuoteItem.Fields.Servi ceDescriptions', 'Views.Fields.Enum', function (Dep) {
return Dep.extend({
translatedOptions: null,
setup: function () {
this.setupOptions();
Dep.prototype.setup.call(this);
this.listenTo(this.model, 'change', function (model) {
this.params.options=[];
this.setupOptions();
this.render();
}, this);
},
setupOptions: function () {
if (this.mode != 'list') {
var entity;
if (this.model.get('discountPolicy') != "None") {
entity = 'Product';
} else {
entity = 'SpecialRateCard';
}
var url = 'Product/action/loadListItemField';
this.translatedOptions = null;
var list = [];
var id = this.model.get('productId');
$.ajax({
url: url,
data: {
id: id,
entity:entity,
},
type: "GET",
dataType: 'json',
async: false,
}).done(function (respose) {
list.push("");
$.each(respose, function (i) {
var val = respose[i].description;
var listVal = val + " - " + respose[i].unit;
list.push(listVal);
});
this.wait(false);
}.bind(this));
console.log(list);
this.params.options = list;
}
},
});
});
Here console.log(list); outputs the values correctly.
But they don't display in the serviceDescripion field ,Giving bad server response.
Can anybody help me in this?
Thanks,
My Account has an option - either discount or rate card.
In quotes if the selected account has discount then quote item will load values from Product. And if it has rate card, quote item will load from Special rate card.
I have an enum field serviceDescription which loads description accordingly.
Espo.define('Advanced:Views.QuoteItem.Fields.Servi ceDescriptions', 'Views.Fields.Enum', function (Dep) {
return Dep.extend({
translatedOptions: null,
setup: function () {
this.setupOptions();
Dep.prototype.setup.call(this);
this.listenTo(this.model, 'change', function (model) {
this.params.options=[];
this.setupOptions();
this.render();
}, this);
},
setupOptions: function () {
if (this.mode != 'list') {
var entity;
if (this.model.get('discountPolicy') != "None") {
entity = 'Product';
} else {
entity = 'SpecialRateCard';
}
var url = 'Product/action/loadListItemField';
this.translatedOptions = null;
var list = [];
var id = this.model.get('productId');
$.ajax({
url: url,
data: {
id: id,
entity:entity,
},
type: "GET",
dataType: 'json',
async: false,
}).done(function (respose) {
list.push("");
$.each(respose, function (i) {
var val = respose[i].description;
var listVal = val + " - " + respose[i].unit;
list.push(listVal);
});
this.wait(false);
}.bind(this));
console.log(list);
this.params.options = list;
}
},
});
});
Here console.log(list); outputs the values correctly.
But they don't display in the serviceDescripion field ,Giving bad server response.
Can anybody help me in this?
Thanks,
Comment