Inventory app logging incorrect values

We created an app to manage inventory that operates on a google sheet with two tabs.

The users submit transactions forms which are recorded to a ledger "Add Stocks" and these transactions edit the quantity of the item on the inventory sheet "Stocks inventory" through a pair of actions triggered by a form submission to "Add Stocks". The formula to update the inventory values is this:

1. Identify the matching entry in the inventory spreadsheet

Select(Add Stocks[Barcode],[_Thisrow].[Barcode]=[Barcode])

Screenshot 2023-06-14 135209.jpg

2. Write the updated value to the inventory entry

Any(select(Add Stocks[Updated],[Reference]=MAXROW("Add Stocks","_RowNumber")))

Screenshot 2023-06-14 135324.jpg

Where "updated" is the new value calculated within the form.

Usually everything works well, except occasionally there will be a cluster of entries that show correct transactions in the ledger, but the inventory sheet updates to the wildly incorrect value. (for example check out quantity 1 and the quantity decreases to -7 from 2.  

After testing I have confirmed the following:

1. If I perform the same transaction again everything works perfectly

2. Usually these errors occur in groups. Like 2-3 transactions will be incorrect consecutively. 

3. I log a time stamp with each transaction and some of the transactions have shown incorrect time stamps. See the image below. The two highlighted transactions occurred an hour later than recorded. Both of these transactions resulted in incorrect inventory levels, as well as the following transaction from that user.  

4. suspecting this was a sync error I have tried to edit the sync settings but this hasn't caused an improvement. Currently all "Cloud to data source" settings are on and I have all but delayed sync turned on for "App to Cloud". 

Screenshot 2023-06-14 133334.jpg

I am not sure what the issue is. Is my second formula pulling the wrong number because of poor syncing? The number off never seems to correspond to other entries on "Add stocks" that are nearby. Again the disconnect occurs in updating the inventory google sheet using the calculated value in the "add stocks" form. 

Also most of the errors, if not all seem to be happening with a user who has an iPhone, but I am not sure if this is a red herring. 

Thanks in advance for the help!

0 3 160
3 REPLIES 3

the stock value should be on a virtual column, not a structural.

Do you mean on the "add stocks" sheet? It is important that we log the quantity of the transaction and the "Updated" value IS already virtual

Here is the data structure for "Add Stocks"

Screenshot 2023-06-14 145624.jpgand here is the structure for "Stocks Inventory"

Screenshot 2023-06-14 145920.jpg

We were able to replicate the issue by simply submitting around 15 sequential requests from two different users. My user (app creator) mostly had correct results, but the other user had many incorrect values.