Questions about Airtable & bardcode scanner

I want to create a website for a study that basically minimizes human error, by taking a picture of a 16 digit code, and outputs 1 of 2 colours. Now these colours will be associated with a code, and the information is on an Airtable CSV. I have started, but I cannot figure out how to pull information from the Airtable after taking a picture of the barcode, and outputing the code. Thanks for the help in advance!


Also, I did search online and there are many blocks that I don’t see when I go into the data blocks

Hi tommydong2010w3eqee, welcome to Thunkable! :tada:

Be sure to check out How to ask Great Questions v2.0, the Community Guidelines, and our Getting Started Guide to make the best of your Thunkable Community experience!

I would recommend looking through this first.

What does your airtable look like?


This is what the Airtable looks like.

Edit: I have edited the code, and I’ve also came across an error:

The row id value is not a lookup field. It represents the row # (1, 2, 3, etc.). You’re using it as though it represents the cell value. What you should do is use the find first occurence of block which returns the row number that a search term is found in.

Would you mind showing me an example of what the code looks like?

The basic idea is from this topic:

The list of values block would be a Data Source block for the column you want to search and the item block would be the text input or variable value containing the search term. If you get a value of zero back from that, it means the value was not found in the column.

Is it like this:

And also, after this, I’m not sure how to approach the goal. Would you mind giving me a simple guide on how you would approach such project?

Thanks for the help!

Almost. The list of values block is already a list so you don’t need to put a + list - block in front of it. That will cause problems because it creates a list of lists. Delete that extra block.

When you set a variable, use the set app variable block at the top of the Variables drawer that already has the variable name. Avoid using the set app variable " " block. You need change those blocks so that it just shows set app variable Code to…

I’m not what the next steps would be because I don’t quite understand what you’re trying to do and what the larger context is (what’s the purpose of this?). I would recommend either clarifying here or using ChatGPT to get an algorithm for your project. That can be a useful starting point.

Yes, thanks, I’ll clarify. So, I need to make an app that will minimize human error by scanning a barcode for a study. Each barcode has a code and each code is linked to 1 of 2 colours, and this data is in the spreadsheets. I want the app to output the correct colour that is attributed to the code when scanned.

If you get stuck, post screenshots of your blocks or a link to your project and someone may be able to help you.

OK, thanks for your help. This is the code I have, and im kind of stuck and don’t know where to go:

1 Like

Your Code and Color variables are going to have the row number where the search value was found. So for example, if you scan the barcode C05202120648900I (hopefully I typed that right!), then app variable Code would have the value 3 since that’s the row in which that Code appears in the data source.

If you then want to get another value from the same row, such as the Colour, you would Get Value of that column for row id app variable Code.

Note: The way you’ve set up app variable Color is probably not useful since it’s only going to find the first occurrence of the value in the Colour column. I would remove that. You also don’t need to have any values connected to the initialize app variable blocks. You can delete the get value blocks that are there. You’ll want to get the values after you find the row numbers.

Thanks for the assistance. But I’m not quite sure how to do the next step. Would you mind guiding me a little? Thanks

Sure. Can you share the project link?

Sure: Thunkable

I made some adjustments, and it kind of works. It outputs the correct output, but only after 2 scans. I fear I may have gotten lucky, and something isn’t correct. Would you mind taking a look? Also, let me know if my project link works.

I would set it up like this (note that I right-clicked on the barcode scan block and chose “show advanced block” so that I could use error handling):

Updated project link: Thunkable

It looks right, but when I try to scan a barcode, it says undefined… I’m not sure what the problem is either.

Add a text input and then set the text input’s text to the green value block. You can then copy (and paste if needed) the scanned barcode value. Paste it somewhere such as a Google Doc. I recommend pasting it between other symbols such as # so that you can see if there are extra spaces, etc. For example, if you pasted " 2345" on a blank page, it might look the same as “2345” but if you use #s as bookends, it looks like this:

# 2345#

vs.

#2345#

Make sure the value there exactly matches the value in your data source.

I copy & pasted a code inside 2 #'s and it looked normal: #C05202120648800K#. I’m not sure what the problem is. Thanks.