I have an app where the user scans a barcode and then enters some inventory information about it. They do inventory once a day. Thus, if the inventory was already recorded, thereโs no point doing the inventory again.
So is this behavior possible?
Thank you for you time,
Doug
@Douglas_Thom
Sure itโs possible. You can use the below expression in Initial Value of the fields:
IFS(
IN([Barcode], TableName[Barcode]),LOOKUP([Barcode],"TableName", "LookupColumnName","ReturnColumnName")
)
Handy little shortcut, and thank you for taking the time to send it, but I think that doesnโt solve the problem of the record being there in the first place. When it saves, the app thinks itโs a new record but the data knows it already exists.
I was thinking something along the lines of an โupsertโ (insert if new key, update if key exists).
You could do this using 3 Actions:
Action 1 & 2: Go to View in this App
New Item >Inventory Form
Existing Item > Inventory Detail (using LINKTOFORM( [ID]=[_THISROW].[Scan]) )
Then create a 3rd grouped action to execute the first two every time you scan a barcode. Iโd go with @Steve 's idea about using a simple table to capture the scan.
Then, under Behavior of Action 1 & 2, use a formula in โonly if this condition is trueโ to make the New Item only run when the barcode value is NOT found, and Existing Item when it IS found.
You can use the IN() function to test for the scanned barcode value in the list of existing Inventory.
IN([Scan],Inventory[ID])
List Expressions and Aggregates
Neat idea! Hereโs how I imagine it working (untested!):
Create a simple table (e.g., Scan) with one column (e.g., Barcode) to receive the scanned bar code. The Barcode column should (necessarily) be both key and label.
Create a (or use the AppSheet-provided) form view (e.g., Scan_Form) for the Scan table. Enable Auto save and Auto re-open.
Optionally make Scan_Form the appโs starting view by selecting it in UX > Options > Starting view.
Create an action (e.g., Edit_Target) to send the user to the appropriate target. Use an action type of App: go to another view in this app and a target formula of:
IF(
IN([Barcode], Inventory[Barcode]),
LINKTOROW([Barcode], "Inventory_Form"),
LINKTOFORM("Inventory_Form", "Barcode", [Barcode])
)
Create another action (e.g., Handle_Scan) with an action type of Grouped: execute sequence of actions. For Actions, choose the Edit_Target action created in (4), above, as the first action, then the AppSheet-provided Delete as the second action. This group action will (once attached, below) send the user to the appropriate Inventory row, then delete the Scan row (without affecting any Inventory changes).
Attach the Handle_Scan action to the Scan_Form view as the Row saved event action. This will cause the action to occur automatically when the user submits the form (which should itself happen automatically as soon as a bar code is scanned because we enabled Auto save for the form in (2), above).
It took me forever to get this set up and running just the right way, but it works like a charm! The only tweak I made is keeping an ID column in the simple scan table and setting it as the key column. This allows me to scan the same item more than once. Thanks a ton, @Steve!
Thanks a lot for this Steve, I had the same issue and now its working like wonders.
Hi Steve,
For step no.5, i created an action with "grouped: execute sequence of actions." However, it did not delete the scan table barcode column data after it link to inventory form view. Even i completed filled the inventory form and saved, it re-directed back to the scan form but the data in the scan table still existed. Do you know why the "delete" action did not execute?
could it be the action will not execute after it link to another form view?
Thank you, all, for your suggestions! They all helped me to come to a solution.
Iโll share it in case anybody is interested later. The entire thing is a bit more complex due to the key to support multi-users, but here is the summary.
IF( IN( [Scanned Barcode], TodayInventory[UPC] ), LINKTOROW( [Scanned Barcode], "Inventory_Detail" ), LINKTOFORM( "Inventory_Form", "UPC", [Scanned Barcode] ) )
Thanks again, Team, I really appreciated the suggestions.
-Doug
Can you provise detailed version please. Iam stuck with the same situation
Quick postscriptโฆ
Now Iโm looking for a way to change the โ+โ on the list to the Scan Barcode action. Even though Iโve assigned it to the Data and View, it will not show up with the โ+โ or in place of it.
User | Count |
---|---|
15 | |
12 | |
8 | |
8 | |
4 |