Reputation: 1
I am doing a development with SAPUI5 where we have two ComboBox ,where first ComboBox displays the company code and based on the selection of the company code the second ComboBox should get filled with related document types.
We have an association from Company code to Document types :
Now on the selectionChange
event of the 1st ComboBox I have written the below code to populate the value of the second ComboBox (Document types)
this.getOwnerComponent().getModel().metadataLoaded().then(function() {
var sObjectPath = this.getOwnerComponent().getModel().createKey("UserControlSet", {
Userid: "Userid",
Ccode: comCode1
});
this.getView().bindElement({
path: ("/" + sObjectPath),
events: {
change: this._onBindingChange.bind(this)
}
});
}.bind(this));
Below the ODATA request is UserControlSet(Userid='Userid',Ccode='HU02')/DocTypeSet?$skip=0&$top=100 HTTP/1.1
Response which get the value based on the bindings where the value is coming properly .
{"d":{"results":[{"__metadata":{"id":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","uri":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","type":"ZMF_STD_JV_SRV.DocType"},"CompanyCode":"HU02","UserId":"","DocTyp":"01","DocDes":"Journal Voucher"},{"__metadata":{"id":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","uri":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","type":"ZMF_STD_JV_SRV.DocType"},"CompanyCode":"HU02","UserId":"","DocTyp":"81","DocDes":"Reversal G/L"}]}} --AEC08A843A15173005FB5AA1E3EF4E020--
But when mapped to ComboBox items aggregation with the navigation DocTypeSet
we get two Values but displays same value as the last one, which is Doctype
81
Need your support to resolve the issue .
Upvotes: 0
Views: 708
Reputation: 870
{"d":{"results":[{"__metadata":{"id":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","uri":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","type":"ZMF_STD_JV_SRV.DocType"},"CompanyCode":"HU02","UserId":"","DocTyp":"01","DocDes":"Journal Voucher"},{"__metadata":{"id":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","uri":"https://example.com:44331/sap/opu/odata/sap/ZMF_STD_JV_SRV/DocTypeSet('HU02')","type":"ZMF_STD_JV_SRV.DocType"},"CompanyCode":"HU02","UserId":"","DocTyp":"81","DocDes":"Reversal G/L"}]}}
UI5 iterative controls like Table,List,ComboBox,Select repeat the last response record if the response has same primary key value. As the response has CompanyCode value as HU02 ie. PK so it's displaying same value as the last one, which is Doctype 81.
Upvotes: 1