[Solved] Looking up RowID using another Cell

Hi all,

First off, total newbie. First app, no prior coding experience, learning it all as I go, so some of this may be messier than it needs to be. I can’t see a similar topic, and any that are seem to have blocks and functions I can’t get hold of… Any and all help is appreciated!

PROBLEM:
I need to delete a row in the Data Viewer List, based on the result of a number picked up in a barcode scan.

THE PROCESS
QR Code scanned and delimited, creates 2 lists. One for stock codes, one for locations
Function to join the two lists with a delimiter into one list
Function should also add an app index (Followed some prompts on another post, but can’t be certain if this works)
Data Viewer List takes the new combined list and makes 2 columns (using get substring); one for location, one for stock code.
Barcode is scanned, text is updated on screen to show the last barcode scanned, and this is used as search string too.

WHAT I WANT TO DO NEXT
Scanned barcode is searched. If match remove the row, if not show error.

WHERE I’M STRUGGLING:
I can search the scanned code in both the separate code list, and the combined list and have a confirmation it’s there. I can see there’s a function to delete row based on rowID. I can’t find a way to… Well if it was excel it’d be an HLOOKUP. I realise this is not proper coding but essentially:
FOR EVERY (J) IN (Combined list)
IF (Scanned Code) = (Code in the list) THEN (give me the row ID)
So I can then
DELETE ROW (Using Row ID)
Refresh

I know there were blocks that had get row options, but they don’t seem to be there anymore. I’ve looked in drag and drop and the old interface just in case. All the help articles I can find seem to use them too.

CAVEATS:
I’d like to do this with the localDB over Airtable or gSheets because I can’t guarantee a data connection all the time, and there may be multiple users.
I need to use Data Viewer List because I need the ability to swipe and assign exceptions.


I’m assuming I’ve way overcomplicated this and can provide whatever screenshots you need, I just can’t post many on my first day so didn’t want to use them up.

Thank you!

1 Like

Welcome to Thunkable

What you actually need is the following:

  • Declare a list as variable.

  • Use the list of values in "table name" .... to fill in the list.
    image

  • Search the list using in list "list name" find first and store the result.
    image

  • Use the result, as it is the index number in the list which corresponds to the row number in the table.

  • With the result, use delete row in "table name"
    image

This should do the trick.

4 Likes

Hello Muneer,

Thanks for replying so fast. You’ve been a saviour on so many other threads so I hope you can help me too!

I’m afraid I do need a little clarification, and I can put screenshots in now.


This is the way the lists get built and organised, including your suggestion at the bottom (The variables are initialised at the beginning)


This is how I interpreted your instructions but it’s deleting the last thing on the list regardless so I’ve definitely made a mistake!

Where am I going wrong, if you don’t mind?

1 Like

It’s easier for me to show you what I mean by a demo project
https://x.thunkable.com/projectPage/62bdcfa3fdabc0001115409b

In this project, I read the data from the table when the screen opens and store the values in two different lists.

The list of letters is displayed in a List Viewer for the user to select from, once selected the corresponding radio word is shown.

I had the row ID from the List Viewer directly and by using the List blocks to get the row ID. The same for the radio word, one directly by the List Viewer index and another by the computed row ID from the List blocks.

Hope this makes it clear.

Looking at you code, I can see that you are rebuilding the list of LST-StockCodes with every iteration of the loop when you only wants to do it one time once the loop is over.

Due to the fact that you are not showing the complete code, I don’t have any idea where, for example SO-Sorted, comes from among other things and therefore cannot comment.

As a suggestion, Deletion is a destructive process and I would leave it to the end. First I would use some labels to show that I am getting the correct (intended) row ID and once I’m satisfied, I will remove extra labels used for the debug process and implement the Delete block.

Thanks so much for getting back to me.

I didn’t know what would and wouldn’t be relevant. I’ve made the project public and you can see everything you’d like: Thunkable
I’m also putting comments on each section to clarify their purpose.

I see the proof of concept but I see you’ve used a List Viewer, not a Data Viewer which does seem to show the index as a usable item straight away. I need to use a Data Viewer as items might need to be swiped to mark if they were missing or substituted etc.

Also though, this is based on a list item being tapped, whereas I’d like this to start after an item is scanned, so the app needs to look through the list itself.

The idea for the app is it’s going to be used for multiple times a day for order processing (hence deleting both the rows as each item is scanned, and clearing all lists and viewers when the order has been marked as completed) so the clean sweep for deleting is involved, but I agree in the debug stage it should just show what it’s editing. Maybe I can replace this with update value to confirmed or something?

Sorry if your examples do what I need and I’m not understanding, this is all very new to me.

2 Likes

They work the same. A List Viewer has a green block Index while a Data Viewer List has a green block rowID.

You can use the rowID of the Data Viewer List to refer to the rowID for the delete block.

If you feel more comfortable with a Data Viewer List, I’ll modify the project to use it.

[Edit]

You can remix the project. I have modified it to use a Data Viewer List.

2 Likes

I can now safely say I am one of hundreds you’ve helped on here!

I had to look at it laterally, and get the Row ID based on a scan rather than a touch but once I’d seen and taken apart how your example worked it made sense. I can’t thank you enough for your help!

Marked as resolved, and you have another person in your fan club :slight_smile:

Thanks again!

2 Likes

That’s good to know and thank you for the nice words.

2 Likes