How to shorten code for an Airtable filter

Hello again Thunkers

Today I read a amazing Post

So I thought This is a amazing idea

Is there anyway where the code could be shorter, or you could give me the final code?

@domhnallohanlon pls can you try to give the answer.

Check this
https://x.thunkable.com/projectPage/5fb9fb1dbfeb240011084d78

When you select a category, the code will filter the table and show the filtered results in the second list.

1 Like

Thanks @muneer

I did not understand the part below, where is SelectedCat:

Screen Shot 2021-02-11 at 2.50.50 PM

this block was inside the Data viewer list clicked event.

1 Like

Basically the DVL (Data Viewer List) lacks a filter criteria and therefore it will always display all the records in the table so as a workaround you will connect the DVL with a temporary table that you will clear all data in this table and fill it with the required data according to the user selection. This is the reason behind deleting all rows in that table.

thanks again @muneer

I went ahead and I came tot his block, can you explain it?

Screen Shot 2021-02-11 at 3.52.31 PM

and how it becomes a row id?

Screen Shot 2021-02-11 at 4.02.20 PM

1 Like

Once you have cleared your temporary table successfully, you know want to populate it with the selected rows from your main table.

First retrieve the column from the main table that contains the row IDs for all rows. This column is created automatically by Airtable.
image

This gives us a list of all unique IDs for the main table.

Now you need to loop through the records of the main table and check if the row meets your criteria.


Here we created a loop to take each rowID from the list and assign it to variable j then retrieve the information in that row using the get block and check if this row satisfies the condition with the if condition if it satisfies then we go ahead and append this row to the temporary table (SelectedCat in this case).

In the end of the loop you will get your temporary table containing only the required rows from the main table.

Hope this makes it clear.

This is another example using free text search

https://x.thunkable.com/projectPage/600c35d2f153060012143dc8

2 Likes

thanks

1 Like