Reputation: 273
In my SAPUI5 app I have an OData operation which works fine. Now I try to show a success message if a new entry could be created and an error message if not. This is my code:
oModel.create("/ImportHeaders", oData, null,
function() {
sap.m.MessageBox.success("Interaction successfully created!", {
title: "Success",
initialFocus: null
});
},
function() {
sap.m.MessageBox.error("Interaction could not be created.", {
title: "Error",
initialFocus: null
});
}
);
This does not show any message box (equal if operation was successful or not). What do I do wrong?
Update to I.B.Ns answer. This code achieves that the success message shows up but although if no interaction was created? Any ideas?
oModel.create("/ImportHeaders", oData, {
success: function() {
sap.m.MessageBox.success("Interaction successfully created!", {
title: "Success",
initialFocus: null
});
},
error: function() {
sap.m.MessageBox.error("Interaction could not be created.", {
title: "Error",
initialFocus: null
});
}
});
Upvotes: 0
Views: 6822
Reputation: 1034
the Model.create method parameters are (sPath, oData, mParameters?), try this:
oModel.create("/ImportHeaders", oData, {
success: function() {
sap.m.MessageBox.success("Interaction successfully created!", {
title: "Success",
initialFocus: null
});
},
error: function() {
sap.m.MessageBox.error("Interaction could not be created.", {
title: "Error",
initialFocus: null
});
}
});
Upvotes: 2