Skip to Content
author's profile photo Former Member
Former Member

success message on omodel create

I am performing a create operation from my UI5 application with below code , and wanted to throw a success/failure message to users. The create operation is successful though, but the message is nt coming up for users.

Is there any additional parameters that are to be added?

Create: function(evt) {
var oModel = this.getView().getModel();
sap.ui.getCore().setModel(oModel);
var requestBody = {};
requestBody.abc = 'abc';
requestBody.cde = 'cde'; 
oModel.create('/EntitySet', requestBody, null, function() 
{ sap.m.MessageToast.show(" Created Successfully", { duration: 2000 });  },
function() { alert('failed'); });
}

Thanks in advance

kumar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Apr 29, 2016 at 09:58 AM

    your code seems correct.put an alert inside success function and see if its being called.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 29, 2016 at 10:12 AM

    Try it with this syntax (naming the callback functions):

    oModel.create("/EntitySet", oEntry, {
           success : function(oData, oResponse) {
                // Success
                sap.m.MessageToast.show(" Created Successfully" );
           }
           error : function(oError) {
                // Error
              sap.m.MessageToast.show(" Creation failed" );
           }
      });
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.