$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
-2

How get the property JSON odata sapui5

May 05, 2017 at 11:31 AM

134

avatar image

I need to get a property JSON in my SAPUI5 Application

 OData.request({
  requestUri : "/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/zset_transferset",
method : "POST",
headers : oHeaders,
data:oParameters
                },
function(data,request) {
                                                    MessageToast.show("Transferência concluida!");       
 //    location.reload(true);
},          function(err) {
MessageToast.show("fail!");
})

I need to show the OData property messageerror(like a image) in my code instead the message "fail"

error.png (56.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Rubens Pereira May 08, 2017 at 06:36 PM
0

I solved it

MessageToast.show(JSON.stringify(data["messageerror"])); 
Share
10 |10000 characters needed characters left characters exceeded
Sharath M G May 06, 2017 at 08:48 PM
1

Use the code, if err is the json ob ject returned from the backend

err.getProperty('/messageerror'))
Share
10 |10000 characters needed characters left characters exceeded
Mahesh kumar palavalli May 08, 2017 at 05:05 AM
1

Hi,

You can put a debuggere inside the error function and see what kind of data is available inside the err parameter. From there you can write your logic to show the error message.

BTW, I hope there is some good reason that you using OData.request method, Ideally the best and recommended approach is to use the OData api availble in sap ui5 library(specifically V2 version). Then you can make you of feature like message manager which does the error handling automatically without you writing any code.

Best Regards,
Mahesh

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu May 05, 2017 at 01:49 PM
-1

yourobject.property.property........ keep going until you reached the property

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Jun Wu, thanks for answer.

Sorry but I am not understand how do it in my code, can you show me a example?

0