cancel
Showing results for 
Search instead for 
Did you mean: 

Correct Changeset Handling in MDK APP

0 Kudos

Hi,

after several attempts I have no idea any more. So I hope somebody can help me out.

So here is what I'm trying to implement:

I'm trying to implement a MDK App with offline store to create a Business Partner. The Business Partner has many many-to-many relations. And to create a Business Partner I have to send all data in an combined format.

I know that many-to-many deep create is not supported in the offline store. So I'm trying now to create a changetset to collect all entities in the app and on sync I want to have one big $batch request so that I can handle this request in the changeset_process method and create the business partner with all naccessary data at once.

So my problem is now. I have an object table with multiple phone or fax numbers created with an CreateEntity Action. But on sync they are all seperate requests. How can I get the created table lines into a changeset action? So that I have the Business Partner (Parent) Entity and the object table items (Childs) in one batch request (Changeset Action)

General Data:

Phone Numbers:

I hope you can understand me :).

Thank you.

PS: I have also seen this post https://answers.sap.com/questions/13085230/group-update-requests-when-syncing-in-sap-mdk.html?childT... but it doesn't help me.

Regards

Alex

View Entire Topic
0 Kudos

Thanks its working now. The request are collected in one batch nice. 🙂

Maybe one more question. How can I achieve that the data I've created in a subpage is directly visible in the table of the parent page? Currently the data is only visible after I've closed the parent page also and then go back to parent without snycing it.

Thanks

Alex

mingkho
Advisor
Advisor

There isn't a straight forward way for this right now. Because any OData operation done within the Change Set is stored in a temporary in-memory location that's currently not exposed and those "pending" data will only be committed to the offline store after the Change Set is committed, that's why you only see the data after the parent page is closed (that's when the Change Set is committed).

Your best bet is probably to separately store them in an array in the parent page's ClientData object after you successfully call the CreateEntity call of the child item. Perhaps in the OnSuccess of the CreateEntity Action of the child item, you have a rule:

export default function SaveProduct(context) {
  var clientData = context.evaluateTargetPath("#Page:TheParentPage_Name/#ClientData");
  if (!clientData.Products) {
    clientData.Products = [];
  }
  clientData.Products.push({
    "ID": context.getPageProxy().evaluateTargetPath("#Control:ProductId/#Value"),
    "Name": context.getPageProxy().evaluateTargetPath("#Control:ProductNameTextBox/#Value"),
    "Description": context.getPageProxy().evaluateTargetPath("#Control:ProductDescTextBox/#Value"),
    "Price": context.getPageProxy().evaluateTargetPath("#Control:PriceTextBox/#Value")
  });
}

And the in your parent page where you show the items in an Object Table, set its Target to:

"Target": "{#ClientData/Products}"

(There's not need for #Page:TheParentPage_Name because this context is already in the parent page)

Note: You'd need to refresh the page when your return to the parent page (in the OnReturning event) to pick up the changes.