on 09-29-2019 5:36 PM
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 ?
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");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
User | Count |
---|---|
78 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
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.