Reputation: 47
I have an UI5 application working with CAP and SuccessFactors.
In my UI5 app, I allow the user to created simultaneously multiple objects in a list in my main model (no name), the user can fill or not the data and save draft.
This data is then sent to CAP which will verify it, upsert it to SuccessFactors and verify if everything went well.
In SuccessFactors, I'm saving the data in a MDF object for which all fields must be filled before upserting, in my UI it is optional, I only send the result message back to the user once the batch finished.
When a batch submission is sent to SuccessFactors and any element creation fails validation, the entire batch fails, and nothing is marked as created in UI5 even though the object is created in SuccessFactors. Additionally, if a user saves a draft multiple times, it duplicates only the valid objects.
I'd like to keep the created or at least set their ID once the batch finished to be sure that the object exist in SF and shouldn't be recreated.
Is there a way to keep the created objects and in the next submitBatch only send objects that failed ?
I'm working with a main, unnamed V4 ODataModel configured like this in the manifest:
OData V4 Model
"": {
"dataSource": "mainService",
"settings": {
"synchronizationMode": "None",
"earlyRequests": true,
"operationMode": "Server",
"updateGroupId": "execUpdate",
"autoExpandSelect": true
},
"preload": true
}
The list in which I'm trying to create elements is a navigation property in the entity.
The binding in the view
<List
id="listId"
items="{
path: 'NavigationProperty',
sorter: {
path: 'Property1'
},
parameters: {
$$updateGroupId: 'updateGroupName'
},
templateShareable: true
}">
This is how an element is added in the Listbinding in the controller
oListBinding.create({
Id: 0,
Property1: '',
Property2: '',
...
},
false,
true,
false
)
And when the user press Save draft
await oModel.submitBatch('updateGroupName')
bHasPendingChanges = oModel.hasPendingChanges('updateGroupName')
In CAP, I verify if there is an existing object in SF with all the property except the ID equals to the properties of the object I received. This solution works at some extent, if after a failed batch, the user decide to modify the valid and now existing object in the list, it will create a new object.
For the moment, I block the save draft if the elements in the list binding are invalid, however this doesn't satisfy the clients needs, the save draft shouldn't take care of validation and only returns messages from CAP
I tried to use the ODataListBinding.refresh() function, resetChanges(), etc. Nothing will actually reload the data. In CAP I return the created object with its new ID but still
Upvotes: 1
Views: 180