Expression to avoid entering of the barcode not from the given list

Hi, I have a field for barcode scanning (I use a usb scanner). I need to prevent a user from entering a barcode which is not in the list (column Barcode, Table ‘Items’). I tried Data Validity (Valid if=), but it gives me a drop-down list in the field for barcode scanner.
Could you show me the direction, please?

Could you try a valid_if condition something like

IN([_THIS], Items[Barcode])

2 Likes

Thank you for your answer. I tried to use your advice, but I get a dropdown list in that field with all the barcodes I have. And I use this field to scan barcodes with a usb barcode scanner.
Is there any other option to forbid entering of the barcodes which are not in the list?

Please share the screenshot of that column’s settings

Here are the settings of the column for barcode scanner:

and

I hope this is the wight way to show the column’s settings…

NNN:

And I use this field to scan barcodes with a usb barcode scanner.

Thank you. In the shared images by you, there is no valid_if setting. Basically, we wanted to know how you have entered the valid_if formula since the query is related to Valid_if.

The use of valid_if in bar code scanning is common. Even though in your case , I am unsure how the USB connected scanner will behave and if it has any specific additional settings etc.
Please refer to the post below wherein a barcode scanner Valid_if is used. The valid_if expression is different but just wanted to share that valid_if setting is common for barcodes. If it is meant to return YES/ No result, it should not display a list. The expression I requested, results into a YES/No result.

Suvrutt_Gurjar:

IN([_THIS], Items[Barcode])

[Does a scanned field override the field's validation?](https://community.appsheet.com/t/does-a-scanned-field-override-the-fields-validation/47624) Questions

We have the following validation in place on a scannable field. The user scanned a barcode into the field and it looks like a period was generated but the field allowed it to be saved. Does a scan override the field’s validation or is there a validation expression problem? [image]

1 Like

Thank you for your answer. I examined the Valid_If Column Constraint article and the use of the function IN(). Unfortunately, I couldn’t find another example for my problem. And again when I use the valid_if condition IN([_THIS], Items[Barcode]) I still get a dropdown list. Here are the screenshots. The valid_if condition is set only for the first field BARKOD 1:

And here are the column’s settings with the valid_in condition:

Valid if “included in column” Questions

Valid If will generate a dropdown if the expression produces a list result, or if the entirety of the expression is an IN() expression. Any other expression will be expected to produce a Yes/No result and will not present a dropdown to the user. Given that, the way to test that a value is in a list without presenting a dropdown to the user is to wrap the IN() expression in some other benign expression: AND(IN([_THIS], select(Reservations[Reservation ID], [Client] = [_thisrow].[Name])), TRUE) (…

3 Likes

Yes! Thank you very much for this link to the similar question. The adding of AND() is a solution of “valid_if” without a dropdown list.

AND(IN([_THIS], Items[Barcode]), TRUE)

2 Likes