I am experiencing an issue with data loading speed from OneDrive and would like your advice.
I created an inventory management file using PowerApps. I have a table named SparePart that stores information about the inventory items, and another table called RequestTable where stock-out requests are recorded with a “Pending” status and displayed in the PowerApp as shown in the image.
Here is the issue:
The current stock of item A is 20. I create a request to issue 5 pcs of item A. After approval, the actual Excel file on OneDrive correctly updates the quantity to 15. However, when I use LookUp(SparePart, KeyID = varApproveItem.KeyID).'Current Qty.' to check the quantity, it still shows 20. Only after about one minute, when the data reloads, does it update to 15 pcs.
This causes a problem: if I issue an additional 2 pcs of item A during the time before the data is refreshed, the system still calculates based on 20, resulting in the stock being updated to 18 pcs instead of 13 pcs.
The same issue happens with stock-in transactions. Stock-in does not require approval. For example, if item B has 1 pc in stock and I add 10 pcs, the Excel file correctly shows 11 pcs. However, the app data has not yet refreshed. If I issue 5 pcs of item B during this time, it calculates based on the old data (1 pc), resulting in -4 pcs.
I would like to ask whether there is a way to make the data update instantly.
The images are attached below, and here is the code I am using for the Approve button and the Withdraw button:
Approve button:
Refresh(SparePart);Patch(SparePart,LookUp(SparePart, KeyID = varApproveItem.KeyID),{'Current Qty.': LookUp(SparePart, KeyID = varApproveItem.KeyID).'Current Qty.' - varApproveItem.'Số lượng'});Patch(StockLog,Defaults(StockLog),{LogID: GUID(),Ngày: Now(),KeyID: varApproveItem.KeyID,Name: varApproveItem.Name,Model: varApproveItem.Model,'Loại giao dịch (Nhập / Xuất)': varApproveItem.'Loại giao dịch (Nhập / Xuất)','Số lượng': varApproveItem.'Số lượng','Đơn vị': varApproveItem.'Đơn vị','Người nhập/xuất': varApproveItem.'Người nộp đơn','Mục đích xuất/nhập kho': varApproveItem.'Mục đích xuất/nhập kho'});Patch(RequestTable,varApproveItem,{Status: "Approved",'Người duyệt đơn': User().FullName,'Ngày phê duyệt': Now()});Notify("Đã phê duyệt và cập nhật kho", NotificationType.Success);Back()
Withdraw button:
Set(varQty, Value(TextInput3.Text));If(IsBlank(cmbUser.Selected),Notify("Vui lòng chọn người Xuất Kho", NotificationType.Error),IsBlank(TextInput3.Text),Notify("Vui lòng nhập số lượng", NotificationType.Error),varQty <= 0,Notify("Số lượng phải lớn hơn 0", NotificationType.Error),Set(varName, cmbUser.Selected.Name);Patch(RequestTable,Defaults(RequestTable),{RequestID: GUID(),'Ngày tạo': Now(),KeyID: varPart.KeyID,Name: varPart.Name,Model: varPart.Model,'Loại giao dịch (Nhập / Xuất)': "Xuất kho",'Số lượng': varQty,'Đơn vị': varPart.'Đơn Vị','Mục đích xuất/nhập kho': cmbMucDich.Selected.Value,Status: "Pending",'Người nộp đơn': varName});Notify("Đã tạo yêu cầu xuất kho chờ phê duyệt", NotificationType.Success);Reset(TextInput3);Reset(cmbMucDich);Reset(cmbUser))

Report
All responses (
Answers (