Skip to Content
avatar image
Former Member

How to parse OData response value in UI5 and display as Message?

Guys,

I have OData service which creates Sales order and returns message as' Standard Order 'XX' has been saved (delivery 'XXXXX' created)</' has been created".(Shown below)

Now i am calling this Odata service from UI5(WebIDE) clicking via button and able to create SO successfully. My requirement is to show this "ExMessage" in a Message box or Pop UP once button is clicked. I am getting the above message in Network-Response, but unable to parse the exact message using Message statement in UI5.

Here is the code below,

function(oData, oResponse) {

sap.m.MessageToast.show(oResponse);

}

And output shown below,

I wanted to parse this "ExMessage" properties Only. Tried JSON.Parse, but it did not help.

Can anyone comment on this?

Thanks

ui5-message1.png (33.0 kB)
ui5-message2.png (24.3 kB)
ui5-message1.png (44.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Sep 27, 2017 at 12:11 AM

    Hi Vivek,

    You may want to check returned param oData.

    function(oData, oResponse) {

    sap.m.MessageToast.show(oResponse);

    }

    See if anything there.

    You can also open chrome developer tools (f12) and put the debug at your code here and explore params oData & oResponse.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 27, 2017 at 01:45 AM

    Hi Tri,

    I checked via Debugging and i did not see oResponse parameter at all. I found only oData and it carry ExMessage value(Reponse message from back end) which we are looking.

    Hence my code is

    sap.m.MessageToast.show(oData.ExMessage);

    This is now displaying what we expect. Thanks for your help.

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 29, 2017 at 04:17 PM

    Hello,

    Just for design purpose, do not use MessageToast for handling error messages. Your end user should miss the information.

    Prefer using MessagePopover or DialogConfirm UI Control.

    Have a look at the SAP Fiori Guidelines for handling messaging

    Regards

    Add comment
    10|10000 characters needed characters exceeded