sfpx Posted January 19, 2017 Posted January 19, 2017 (edited) Sorry for the vague title. Let's suppose 2 tables Table Travels (travelID , carID, destinationID) Table Cars (carid, lastdestination) What I want is to update the lastdestination field in the table cars each time a travel is deleted. What I tried is 1.When a travel is deleted on the phone, I update the car modification time stamp to make sure it gets synced. 2.In the customization script in the "A RECORD WAS UPDATED ON THE HUB" section I added If Get ( LayoutName ) = "cars" set field [lastdestination, last(travels::destinationid)] 3.I deleted the last travel of a car and synced. The lastdestination field was not updated. I guess that this is because the deletion of the travel record is done after the car record update. 4. If I update the car on the device again and sync...then the field gets updated. Any way to achieve what I want to do ? Can I force the car table to be synced last ? P.S. Different users can use the same car. I can not use a calculated field to determine the last position on the device because the other user travels are not on the device. Edited January 19, 2017 by sfpx
Jesse Barnum Posted January 19, 2017 Posted January 19, 2017 1) Which exact version of MirrorSync are you running? 2) In the MirrorSync configuration, do you have a foreign key configured from travels to cars? Actually, I just realized that neither of my questions matter, because we always do inserts for all tables, then updates for all tables, then deletes for all tables, so the delete will always happen last. You could edit the 'WillDelete' section for the hub, and in the travel table, you could update the related car record at that point. I don't know whether that will sync the car record back to the client though.
sfpx Posted January 19, 2017 Author Posted January 19, 2017 5 minutes ago, Jesse Barnum said: Actually, I just realized that neither of my questions matter, because we always do inserts for all tables, then updates for all tables, then deletes for all tables, so the delete will always happen last. You could edit the 'WillDelete' section for the hub, and in the travel table, you could update the related car record at that point. I don't know whether that will sync the car record back to the client though. I thought about the willdelete section. I haven't tried it because I assumed that the data would not be sent back to the client. I may try it to see.
sfpx Posted January 19, 2017 Author Posted January 19, 2017 (edited) I just tried the following in the WillDelete section If Get ( LayoutName ) = "travels" set field[cars::lastdestination, "x"] I deleted a travel on the device and synced. The lastdestination field on the device was changed to "x" ! So the modification is sent back to client. The problem I have now is to modify my calculated field so it ignores the travels that are going to be deleted. Can I write something in the record that is going to be deleted or will it cause a problem ? EDIT Got it to work 1.created ToBeDeleted field in the travels table 2.modified the relation between travels and cars so the ToBeDeleted travels records are ignored 3.In the willdelete section I set the field ToBeDeleted of the travel to 1 and reevaluate the lastdestination Edited January 19, 2017 by sfpx
Recommended Posts
This topic is 2863 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now