on 2024 Apr 05 7:39 AM
Dear Support.
We want to call an api created on RAP ( Odata V4). We read information about our question here https://sapui5.hana.ondemand.com/sdk/#/topic/fbe1cb5613cf4a40a841750bf813238e.html and here https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/b9a77576783a455cbff617c...
Upon appending messages in failed messages, they are correctly displayed in the response payload. However, when we append information or success messages in the reported section, for example:
Messages are included in the response header, with a limitation of 20 records.
But not in response payload
Is there any chance to report messages in the response payload? How are then appended the messages?
Regards
Hi,
I'm also trying to figure this out. If you're developing using freestyle SAPUI5 and Javascript, you could get those messages like this:
SCENARIO 1: I want to get all messages from my currently running session
// prerequisites: any combination that triggers POST call to backend, example below - I assume you have it
let oBinding = oModel.bindList("/EntityPath"); // access create method via list binding
oBinding.create({...}); // one or multiple .create() calls
oModel.submitBatch("batchCreate"); // summarized in one batch
// you need just this snippet to get all messages from your current session: if you don't mind, that you can't delete previously received ones
oModel.attachDataReceived(function (oEvent) {
let oSource = oEvent.getSource();
let aMessages = oSource.getModel().getMessagesByPath("/EntityPath");
});
SCENARIO 2: I only want to get new messages every time I'm creating an entity, so I don't get old irrelevant information
oModel.attachMessageChange( function(oEvent) {
let aMessages = oEvent.getParameter("newMessages");
oEvent.getSource().setMessages({ "/EntityPath": aMessages });
} );
Instead of calling .attachDataReceived(), you could also utilize MessageProcessor by .attachMessageChange() ( hiding in oEvent.getSource() ) and set your messages either by receiving only new messages (in parameter newMessages) or even including oldMessages parameter (refer https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.core.message.MessageProcessor), if exists.
I would recommend some independent storage for that data (ex. custom data). Overriding existing Message arrays/objects might get tricky, because you're still at risk of mixing old messages with new ones.
EntityPath is obviously your alias connection to entity maintained in Service Definition - I assume you have it covered as well.
Although, I'm not sure whether you can receive details about your Entity Key in particular message. I think this has to be maintained manually. If someone knows how to achieve it directly, let us know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
11 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.