Sync two tables when one fails
Application Type

Hello all-

I have a mobile app that has a local transaction table and a local image table.  An Id number is given to the transaction record when created.  When a picture is taken for the record it is stored it is given an id of a nullidentifier and the transaction identifier generated when the parent record was created so can be a one to many relationship of transaction to images.  I have consolidated this all into one server action for an offline data sync

My issues is when I sync sometimes the connection will time out, no idea why (BTW is there someway to find out).  I have set the offline datasync configuration to retry on error.  When it does this I sometime get an primary key insert error on the server side because the all records are sent again.

Is there any way I can keep this from happening? 

Thank you


You shouldn't use the Id that is sent from the mobile application for a primary key on the server side, as that won't work when more than a single mobile app is connected, and you get the problems you are facing.

In general though, you could first read the database to see if a record with that key already exists and see if anything changed, or you could use a CreateOrUpdate instead of a Create.

Can you point me in a direction that allows me link these two tables without generating a key in the mobile app?


You can always send the Id on the mobile side, and store that as an external identifier on the server side, if you have no other means of uniquely identifying the data.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.