When trying to create an inventory system, I want to be able to delete a row/entry from a previous check out by using only the bag number to find and delete the row. I have tried many different things, from the very simple of basically doing the same thing as the create block(which didn’t work) to the more complex version that I uploaded. What can I do to solve/fix my situation?
Hi there,
The process you are following in these blocks is:
Get Column
Find index of a given barcode
Retrieve that row object
Delete the row at the location [row object]
Of course, what you want to do is delete the row at the index you just found!
So you don’t need to ‘in Table call GetRow’ block at all.
In the ‘rowNum’ field of the ‘in Table1 call DeleteRowNum’ block, put your ‘in list find first occurrence of item’ block, exactly as it is in this example.
Your new procedure will be:
Get Column
Find index of a given barcode
Delete the row at the location [index]
Which is what you want to do!
Hope that helps, let me know how it goes.
Thanks for the reply!
I tried to fix it, but i may have misunderstood what you said partly, what do you think went wrong here? It doesn’t even initiate the error message anymore.
I tried this, too, and found that if the DeleteRowNum block tries to delete row zero (0), it will not return an error. This shouldn’t be the case but since it is, you’ll need to check to see if the list block returns zero. The way I did this is to assign that entire rowNum block (starting with “in list”) to an app variable and then check to see if that app variable value is 0 below moving on to your next if/do/else block.
I reported this issue here: https://github.com/thunkable/thunkable-issues/issues/344.
So if i technically left the first cell of my table full at all times, would this also get around the issue? When i tried to reveal what value the in list is getting back by setting it to a label after it is run, it outputs nothing at all, which means it overrid my original set to 0 when initialized, but set it to absolutely nothing.
It has nothing to do with the length of the list/spreadsheet. When you do a “find first occurrence of item” block, it returns the number of the item (in this case the row number from the spreadsheet column) that matches the search term. If it doesn’t find a match, it returns zero.
You could have 1,000 cells in your spreadsheet all populated with “French fries” as the cell content but if you search for “tomatoes”, that block will return 0.
Thank you for helping me with this issue! The issue i have currently is that even when it does match an entry in the database, it errors(or still sets it to 0). I made this block to try what you said, but unfortunately I think the issue that I am getting is that it may not actually be finding a row number at all. With this new block, it actually pops up with an error message, but it does that even when I put in a valid result.
So I think what its down to right now is that when it does a find first occurrence, it seems to not be actually returning a row number, is there a fix to this part?
What happens if you replace “from BarCode_CheckIn get text” with an actual text string with a search term you know exists in that column of your spreadsheet? If that works, it will at least point to the text input as the problem.
Okay, so i tried that and it worked, so i decided to try creating a new box and using the new box, and it worked!.. But only for like a few minutes until it breaks again and gives back the value 0 again until i create a new box, then it works for another few minutes. The code is staying the same from when it works to when it doesn’t work, so what is going on?? Super weird occurance, I even tried to set the textinput as a variable then finding the occurance of the variable, and that worked for a little bit, then didn’t.
Sounds like you’re probably suffering from a bug related to this one: Thunkable X Blocks Update - Your feedback
(bug report at https://github.com/thunkable/thunkable-issues/issues/345)
Thank you for linking it, i’ll make sure to post on there so that it can be fixed.
@tatiang @jane
Is this code good as is? The code still not working after they said they had partially fixed it. I just want to make sure that it’s the bug and not my code. When testing with a valid number, it gives the bag not found in my code, which would mean that it is either not finding the row number, or it is never getting changed and is sticking at the original default value.
So your code is firing when app row = 0 which as you said means that the search term isn’t being found in the spreadsheet column.
As to why that is, my guess is the text string space bug I linked to. To know for sure, have you used a label to display from Text_Input3 get Text? If so, does it appear correctly, just as you typed it in?
Sorry, I hadn’t looked back at this forum until just now. I’ll update you when I try it out in a few.
No problem. Things just tend to get a little confusing when problems are posted to multiple topics. I’m happy to help if you provide more info about what’s happening.
It does seem to appear perfectly when using a text to label block. Now I’m sort of perplexed on what is going wrong.
My code hasnt changed since last screenshot, is there anything still wrong with it? or is the bug still existing?
I haven’t seen an update about the bug so I’m not sure.
Hello All, I’m able to write to the spreadsheet without issues. I’m also able to pull the data back into my app and display it like I want. Deleting the row works great too. My issue is, I have 3 columns in my spreadsheet and when I write to one, it enters the data in the next highest row number if you compare all three columns. This make it impossible for me to delete the entry. If I have just 1 column it works just fine. How can I add the data to the next available row in each column? (See my Airtable screenshot.)
can you describe your use case a little more?
do you have to use the database?
Will you ever filter results based on user/date?
are you concerned with using all of your rows in airtable?
Have you considered saving/retrieving lists of variables to accomplish this task?
using the local DB and storing each column under it’s own key maybe?
if you don’t want to skip rows, you could consider using 3 separate tables. or if the user simply doesn’t add info for that cell, enter have the app auto-enter something like ‘n/a’