on 2019 Oct 11 10:44 PM
Hi,
My back-end table has 2 primary keys and it expects me to pass both the values to remove/delete records from the database.
ODataModel.remove() method doesn't have any PayLoad or filters parameters. The URL parameter which is available I guess cannot be used to pass values, it is for $expand, $top, etc. So what's the way out here....
//Neither this works
oDataMdl.remove("/<EntitySet>?$filter=Key1 eq 'Value_1'"
//Nor this works
oDataMdl.remove("/<EntitySet>('Value_1')"
On top of this I need to pass two values and just one. Any suggestion please ?
Request clarification before answering.
oDataMdl.remove("/<EntitySet>(keycolumn='Value_1', keycolumn2='key2')"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to pass both keys as mentioned by jun.wu5..
You can get the path in a dynamic way by using create key. See the question below.
https://stackoverflow.com/questions/46954621/how-to-create-entity-path-dynamically-in-ui5
Thanks
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried Jun Wu's suggestion last week and it worked. Thanks Mahesh for showing me an alternate option as well.
Now then,..once I delete a record, I am trying to refresh my model so the table to which the model is bound shows latest set of records...which is not working though. May I know how we can refresh the model after delete method is invoked. Or, the only way to show latest records (post deletion) in the table is to again call a READ method and get the records from the back-end ?
var oTab = sap.ui.core.Fragment.byId("DOCSUPLOAD", "idTabDocList").getModel("docsList");
var oDataMdl = this.getOwnerComponent().getModel();
oDataMdl.remove("/<EntitySet>(keycolumn='Value_1', keycolumn2='key2')",
{
success: function(oData, oResponse){
sap.ui.core.Fragment.byId("DOCSUPLOAD", "idTabDocList").getModel("docsList").refresh();
MessageBox.show("Success");
}.bind(this),
error: function(oError){
MessageBox.show("Failed");
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
30 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.