Hello Experts,
I am facing issue while inserting record in database.
Scenario:
1. I am using mobile application with data synchronization.
2. I am creating or updating records in local entities then syncing it to server.
3. I have 2 entities: Equipment calibration(main entity) and Equipment Calibration Upload(one to one relationship)
4. I have 1 form in which i have to fill some data and upload file at the end of form. For saving binary file i am using EquipmentCalibrationUpload entity.
5. In the save action, first i am saving all data of main entity and then using createOrUpdateEquipmentCalibrationUpload action in which i am passing ID which come from main entity.
6. When i am saving form main entity details are saving but file is not uploading.
Please suggest some solution.
Note: Refer screenshot.
Thanks and Regards,
Nayana
Hi Nayana
I managed to replicate the issue that you are having by building my own small app similar to what you built and I got the same foreign key error.
This is what I can see from my test:
I hope this explains your issue and that you have a better idea on how to fix it.
Hi Nayana Sonawane
Usually, for these cases, we use a one-to-one relationship between the detail entity and the detail binary entity, and the most common error is when we are creating a new record the ID that is been sent on the binary entity goes null. So after you save the detail, you must set the ID of the binary as CreateOrUpdateActicon.id.
Something like this
I think this is your problem because you forgot to upload the screenshot ;)
Hope this helps
Regards
Gonçalo Almeida
Hi Nayana, I don't see a screenshot on your post, could you please add your screenshot?
I have a question though.
Are you using the createorupdateequipmentcalibrationupload action directly or are you using the
createorupdateequipmentcalibrationuploadFORSYNC action?
You should be using the action that ends with ...FORSYNC.
If you don't have those actions you have to create them. Right-click on your local database entity and click create action to sync data (read/write)
Also, when you test the app, are you testing on a computer or are you testing on a mobile device using a native app that you installed? Sometimes the local storage on a computer does not behave as it should on a device and you can get foreign key errors.
Please check attached screenshot.
I am using for sync action. Also for binary entity Id, I am using ID of my main entity i.e. CreateOrUpdateEquipmentCalibration.id.
When I debug app on computer, Id is correctly passing but getting error at server sync action.
Nayana Sonawane
Can you send a screenshot inside of that server the SyncEquipmentCalibrationUploads?
It's possible that you are using a create action or an update action instead of a createorupdate.
Hello @Vonnelize Haupt ,
Thank you for solution. It really works.
I appreciate your response on my post.
Regards,