so i am trying to create a scanner like what every store have, so when i scan a barcode the series number is added to the spreadsheet row, but i don’t want to every time i scan, it creates a new row, rather i just want to add the quantity, what model of blocks should i build? thank you
What you’re describing is a vlookup where you search one column for a value (barcode) and then update a different column’s value (quantity) in the same row.
Search the forums for vlookup and you’ll find examples of this.
alright, hang on
So, sir, somehow i am able to reach this block structure, it successfully avoid multiple data by giving it an if condition, but i still unable to add quantity on every data i added, do you why? thank you
Thunkable evaluates each block or block combination for a value. So when you have the blocks x=x+1 where x is a variable, that evaluates to false because each side of that equation has a different value.
I know you were trying to increase the value of the variable by 1 in the screenshot below but that’s not what the equals block does in Thunkable. It compares two values and returns true or false. So your blocks are attempting to store the value false in the data source.
To fix that, remove the = block and just store the value of your variable plus one (x+1).
How are you setting the value of app variable quantity? And how are you initializing that variable?
Feel free to post a link to your project if it’s easier than posting more screenshots.
https://x.thunkable.com/copy/5f3fb1ba8fe2df06c5182205176d0fec
here, can it be opened?
Yes, I was able to open it. You are initializing app variables quantity as a list and then trying to use it as a number.
This is called mixing variable types and should be avoided.
Delete the list of values block from the initialize block for that variable. You do not have to give an app variable an initial value but if you want to, you can set it to zero.
You also need to set the value of app variable in the click event block to the current value of the data source cell that you want to update. That way, when you add one to it later, it provides the correct value.
hi sir, i successfully avoid Nan on multiple scan, but the quantity still unable to increase, is there any kind of blocks rule to get the increment process? thank you
You’re not setting the value of app variable quantity anywhere else except when initializing it. Before you save app variable quantity + 1, you need to increase the variable’s value by 1 and then save the value of the variable to the data source. Sorry, I’m on my phone so I can’t post a screenshot of the blocks you need.
i tried, but it is stuck in 2, no more increments after multiple scan process
This is not a valid number.
It might be, depending on the country.
@tatiang Interesting, I never knew that. That might be his problem though. Thunkable might see that as a string.
is it because you set it on list? so it returned on list
Try this. In this version of your app, when the screen opens it sets a variable to a list of all the products on your google sheet. When you scan a new product, it will save it to your google sheet and also the local list variable. This will help speed up the scanning process as well.
Edit: You can remove text component I added. It was used for testing purposes.
https://x.thunkable.com/copy/f68d7419fd5f1bc5610b9302f45aac73
still stuck on 2,00 on spreadsheet sir, i do not know why, but im still trying to figure it out