I'm new to AppSheet, I'm trying to have a survey where the user scans a barcode and if the barcode is already in the database do nothing but if the barcode is not in the database redirect the user to a new view where a different survey is set up to introduce that barcode to the database. Hopefully executing once the user scans the barcode instead of having to hit save on the current survey before the code executes.
Here is the logic I have so far:
IF(
IN([Barcode ID Input], ITEMS[Barcode ID]),
"",
LINKTOVIEW("New Items")
)
Which makes sense to me but I don't know where to put it or set it up, so that directly when the user inputs the barcode the code executes. Any help in this manner will be helpful. Thank you for your help.
Solved! Go to Solution.
In your first table where you scan the barcode, you can make the scanning field a Ref pointing towards the ITEMS table, while the "Barcode ID" column is a Label for that table.
Upon scanning, the user will have the option in the field of choosing a matched scan from the ITEMS table or add a new entry, which will navigate him to the Form View of that table to add a new item.
You can prevent the user from saving the Form without first adding a non-existing item by dereferencing the value of any column in the ITEMS table, and make a Valid if constraint for example: ISNOTBLANK([_This])
In your first table where you scan the barcode, you can make the scanning field a Ref pointing towards the ITEMS table, while the "Barcode ID" column is a Label for that table.
Upon scanning, the user will have the option in the field of choosing a matched scan from the ITEMS table or add a new entry, which will navigate him to the Form View of that table to add a new item.
You can prevent the user from saving the Form without first adding a non-existing item by dereferencing the value of any column in the ITEMS table, and make a Valid if constraint for example: ISNOTBLANK([_This])
Thank you very much, it work well. Now I'm wondering if when we scan a barcode and don't find that barcode in the database. Is there a way to carry the already scanned barcode into the "new item" form such that the user doesn't have to scan the same barcode twice?
Scanning once, hmmmm, good question. Maybe if you make your barcode column also Key to the ITEMS table.
I already had the barcode column as a key and it doesn't seem to pass it. Here is my data table for "Items".
I mean is not the end of the world but I wanna try and make it as easier as possible for the user.
@Gab0c wrote:
make it as easier as possible for the user
๐ ๐๐ Well done!
In the initial value of the barcode key column, try:
INDEX(
SELECT(Form Data[Barcode ID Input],
IN([formDataKey], [_ThisRow].[Related Form Datas])
),
COUNT( SELECT(Form Data[Barcode ID Input],
IN([formDataKey], [_ThisRow].[Related Form Datas])
))
)
When I substitute "formDataKey" with the data key from the "form data" table which is "_RowNumber." I get that a circular schema has being created, "Expressions in schema 'Items_Schema' have a circular definition. Check app formulas and initial values for column 'Barcode ID.'"
The problem is that "_RowNumber" will not have a value until the form is saved; actually you use it to know whether you are editing an existing row or adding a new one.
Try using another row as key please.
Thank you for your help but at the end the supervisor said to not worry about adding a new item from that form. Thank you for all your help.
User | Count |
---|---|
15 | |
12 | |
9 | |
8 | |
4 |