cancel
Showing results for 
Search instead for 
Did you mean: 

Android SDK - Odata Offline - create entity - Keys never setted - Entity stays local

yohann_weberfr
Explorer
0 Kudos

Hi Experts,

I work on an Android app with SAP SDK for Android 4.0.1

I work with an offline odata.

I am facing an issue with the creation of an entity.

I want to create an entity "Avis" and let the backend generates the key. So I use the methode entity.unsetDataValue(Avis.numeroAvis) to unset the the key of the entity. I expect that the backend creates the entity and sends me the key. That it do, i have an response like this, where key NumeroAvis is setted :

But in my app, the entity created locally is never updated with the key and is still marked like "local"

I thinked, this issue comes from a broken link between the local entity and the answer entity during the update. I saw, the app or SMP send some html header like "requestid" and I copy this tag to my html response. But it doesn't work

Maybe this issue could come from my loading structure ? To be more efficient, I only use one request with and only one expended entity in the backend side :

val pointDeMesureSetQuery = OfflineODataDefiningQuery("EnteteSet", "EnteteSet?\$expand=AvisSet,OperationSet/AvisSet,OperationSet/PointDeMesureSet/DocumentDeMesureSet", false)
addDefiningQuery(pointDeMesureSetQuery)

Could someone have an idea or faced the same issue ?

At least, does an documentation exists about good practice with app and backend offline odata conception ?

Thanks a lot

Yohann

Accepted Solutions (1)

Accepted Solutions (1)

lxsun
Employee
Employee
0 Kudos

Hi Yohann,

By default, upload/flush will only send local request to backend and won't update local entity and covert it to a server entity. Download/refresh will convert local row to local row.

If you don't want call download to get key property populated, you could set early_populate_backend_generated_values to Y in endpoint's configuration . You could find guide here:https://help.sap.com/docs/SAP_MOBILE_SERVICES/468990a67780424a9e66eb096d4345bb/808879518866488583f7350f9414538b.html?locale=en-US

As document mentioned, the server side generated key will be used to populate the local entity. Local entity will be still local entity, even some properties come from server.

Thanks

Leon

yohann_weberfr
Explorer
0 Kudos

Thanks for your answer Leon, it's totally right.

My entities weren't updating simply because of my GET.

During synchronization, the SDK first launches all updates (PUT/POST/DEL), then refreshes the local data with GETs.

My (wrong) idea was that the statuses of SDK-side entities updated when POST returned. However, they are updated when the GET returns!

In my case the GET returned nothing, and therefore the SDK did not update anything.

During POST, the SDK only updates keys (if necessary)

In the end, there is no link made from the headers as I thought. It is the link through the keys that allows the SDK to find the entity and update its data, status, etc. when returning from the GET.

Answers (0)