cancel
Showing results for 
Search instead for 
Did you mean: 

Supressing OData message on UI5 screen

former_member243729
Participant
0 Kudos

Hi,

I am using oDataModel.submitChanges() method and have a success and error callback methods implemented. When submitChanges method gets invoked, I get a meesage back from back-end as below which is fine.

1) My question is, ..why does this message come even before the call back functions are invoked ? Should not this message come when either success or error call back is invoked ?

2) How can I hide the 'show details' part of the error message while I still want to keep the pop-up error message ? As, show details will confuse users due to its technicality.

Below is the code I use..

oDataApprvMod.submitChanges({groupId: "appr_submit",

success: function(oData, oResponse)
{
if(oData.__batchResponses[0].__changeResponses != undefined)
{
if(oData.__batchResponses[0].__changeResponses[0].statusCode == '201' && oData.__batchResponses[0].__changeResponses[0].statusText == 'Created')
{	
MessageBox.success("Program submitted for approval successfully", {title: "Success"});
  		}
    	}
   }.bind(this),

 error: function(oError){
   }.bind(this)				 
});

Below is the Error message I get (screenshot). I want the error pop-up message but what to remove the 'Show Details' part.

So some one suggest me how to handle it ? Is it handled in UI5 or in the back-end ?

screen-shot-2019-09-29-at-113411-am.png

Accepted Solutions (1)

Accepted Solutions (1)

former_member243729
Participant

Found the solution.

oDataApprModel.attachRequestFailed(null, com.XXX.util.messages.showErrorMessage);

the above line of code in controller and then have a method implemented in util class to parse the error message. This way you can get to the error message and error detail part. Initially I was showing error details also which I now commented out...that way I now only show error message and no error detail to user.

var sMessage = "",
sDetails = "",

if (jQuery.sap.startsWith(sDetails, "{\"error\":")) {

var oErrorMod = new sap.ui.model.json.JSONModel();
oErrorMod.setJSON(sDetails);
sMessage = oErrorMod.getProperty("/error/message/value");
}
rsletta
Contributor
0 Kudos

Thank you for providing your solution, for future reference. 🙂

Best regards
Ronnie

Answers (2)

Answers (2)

former_member243729
Participant
0 Kudos

I am actually using eclipse, so its not a template. But still I should be able to follow your suggestion. Let me try and get back to you. Thanks.

maheshpalavalli
Active Contributor
0 Kudos

I think you generated the fiori app using the template. So with the template, there is a file called "ErrorHandler" generated in the controller folder, check that file. That file throws an error if any request fails. You can do the modifications there.

Thanks

Mahesh

former_member243729
Participant
0 Kudos

I just created an application using template in cloud WEIDE but do not see any error handler file any where in the created project.

former_member243729
Participant
0 Kudos

I see that on the controller, below code is what is triggering the pop-up with message coming in from back-end. I am fine with this message, but want to hide the 'show details' part in the pop-up from user as the details are very technical. Any suggestions ?

oDataApprModel.attachRequestFailed(null, com.XXX.util.messages.showErrorMessage); 
maheshpalavalli
Active Contributor
0 Kudos
Venkata Sunil Naidu Chennam, Cool.. First thing came to my mind is the errorhandler as it's in the latest version(from 4 years atleast). Probably you are using the old version or some custom application or standard application extension.Br,
Mahesh