Using row id and if statement

Brand new to this so here’s a softball.

I have the following data table:

Screen Shot 2024-04-07 at 4.41.03 PM

If the user clicks on the first item in the table’s data viewer, I want to navigate them to a screen. For all of the other items, I want the row’s text to appear in a text box. When I click the first [Add New Customer] item, instead of navigating to a different screen, it fills in the textCustomerName box with “[Add New Customer]”. So the else condition is functioning properly but something is wrong with my if statement.

How do I get it to navigate to a screen if they select the first item?

Your logic is sound but the row id in the green block is not an integer value. It’s a long text string like “asd3278546$h8k”.

So comparing it to 1 doesn’t work here. I don’t recommend setting up your data source with button text in the first row. I can see how it’s tempting to want to do that so you can use a Data Viewer List. If you remove that and make it a separate button on the screen, this logic will become easier and everything going forward will be easier (rather than trying to deal with the first customer being in the second row, etc.).

Interesting. I never would have thought that a row id is a string.

And I’ll take your advice - I have the space for it.

For edification sake, if you had to do it, how would you do it? Use a for loop to assign a variable name like row# to each row? where row1 is first and then use a +1 operation to iterate the naming of the variables?

Yes, you could do that. And it works to refer to row ids using integer values. It’s just not what the green ‘row id’ block returns. I think it has to do with React Native which is the language underneath all of the blocks. Everything in Thunkable has to have an id and you can imagine that without that, it wouldn’t be easy to differentiate between row 4 of one data source and row 4 of another data source.

1 Like