cancel
Showing results for 
Search instead for 
Did you mean: 

V4 Odata save / submit / create new record with FeedInput sapui5

former_member374496
Participant
0 Kudos
1,943

Dear Expertise,

I am working with oData V4 version and facing little issue when i click on post comment button.

When user enters the comment and click on pot the comment should get save in the db table/entity, As there the model is not bind to this component so don't understand how do i achieve this ?

When i click on the post i need to send the comment, and other parameters like user ID etc...

View.xml :

<FeedInput placeholder="{i18n>label.common.addComment}" showIcon="false" post="onPostComments"/>

in controller:

onPostComments :function(oEvent)

{

// here i need to get the comment and form a data and send to the db.

}

my odata v4 service to save is something like this:

http://localhost:8080/api/WorkflowService/Workflow(3ef86f62-3ef2-44cf-84b3-26f843c4672a)/comments

how do i bind this to FeedInput?

Thanks in advance :

Pradeep

View Entire Topic
maheshpalavalli
Active Contributor
0 Kudos

Did you try this?

https://ui5.sap.com/#/topic/c9723f8265f644af91c0ed941e114d46

I hope you did element binding of workflow id & comments (navigation) to the feed list. Later use the code from the above help link and create the data .

or like this

https://ui5.sap.com/#/topic/b4f12660538147f8839b05cb03f1d478

former_member374496
Participant

Hi Mahesh,

Thanks a lot for the suggestion and help, this worked for me :

onPostComments: function (oEvent) {

      let oModel = this.getView().getModel("WorkflowModel");
      var comment = oEvent.getSource().getValue();

      var cmmentsEntity = {
        "user_UUID": "xxxxxxxxxxxxx",
        "comment": comment,
        "workflow_UUID": xxxxxxxxxx,
        "type": type
      };

      var oContext = this.getView().byId("workFlowCommentsList").getBinding("items")
        .create(cmmentsEntity);

      oContext.created().then(function () {

        oModel.submitBatch("WLEGroup").then(function () {
          if (!oModel.hasPendingChanges()) {
  
            MessageBox.information(succMessage);
          } else {
  
            MessageBox.error(noSave);
          }
        });

      }, function (oError) {
        MessageBox.error("Cannot Create a comment");
      });

     
    }