Airtable features

Hi Guy,

just need some opinion about airtable.

how to display record id as per screen shoot below? i want to be standard formation number for example 1,2,3 whenever record deleted in any row it will automatic fix according standard formation.

image

2 Likes

What is your input value? Are you taking the row ID and then getting the row # (as circled in your screenshot)? Or are you searching for a Name/Nama and then getting the row #?

??? → row #

When I delete a row in Airtable, the row #s automatically refresh:

1 Tomato
2 Carrot
3 Potato ← delete row
4 Onion
5 Celery

1 Tomato
2 Carrot
3 Onion
4 Celery

Does that not happen for you?

1 Like

So from my understanding since you highlighted the row numbers, you would like to see the row number in thunkable right? I would say that you should pull all rows from airtable without any filters and store them in a variable as a list with a for loop that increases +1 in a for loop during the data storage, then when you delete, you may need to have a function that also changes the data already stored (as to avoid multiple requests via the SDK or API); Something like once something has successfully been deleted, find its position in the list, remove it, then re-format the data with the count variable to reflect this change.

So if you remove row 5 from airtable (and it looks like “5. Fathi” in your thunkable list) then your function to reflect this can be something like for each item j… join "count" + ". " + "in text j get substring from letter (find first occurence of text .) to last letter. That way you will not need to make a request from airtable to begin again, and the data so long as the list is never filtered should correspond correclty to the data in airtable.

If this is your goal, I can help you test it out. This is just a solution I came up with but there may be a better way to do it as well. If this is not your goal, please give us more clarity. Unfortunately, airtable row ID is not a number but a string of characters, and their “autoNum” column data type does not automatically adjust as far as I know which can get quite frustrating when the blocks require a row number.

exactly that happen at my airtable but what i want, how to display from selected row to thunkable including row id?

image

yes that what i want. auto number function in airtable it does not automatic change after we deleted the some of row. for example the row 1,2,3,4 and we delete row no 2 the autonumber column become 1,3,4.

1 Like

@ozel1978 Not a problem, I made a quick project to test this out and found something that works based on my inital comment. Here is what the table looks like in airtable:

image

I think you have more data (both vertically and horizontally) but this still should work regardless. As you can see, the data structure is based on the screenshot you provided. I was able to make this work by declaring 4 variables so that we may sort and filter the master list and control for scenarios where you may filter the results to only show specific data (e.g only show everyone whose Number ends in 6). Below are the blocks, screen components (so that you can see what is being pressed or changing state), and variable declarances:

Variables
image

Note that I used app variables, but if you require the data to be kept between sessions, a stored variable/stored variables will work as well.

Screen Components

Getting the Data (unfiltered)

As you have noticed, I stored the data in the master list as a JSON, personally I prefer this method as we can easily get the specific data point we require with ease as we can just call it’s object property name as opposed to applying complex text filters that need to account for spaces and data of different lengths. If you are not familiar with it, I highly recommend getting familiar with it for ease sake and use for APIs or other database types, however you do not have to and can store the data as you see fit. An alternative would be to save it as a comma seperated text (example below).

Comma Seperated Text

As a JSON, the data structure I used looks like this:

{“number”:“value for Number column”, “nama”:“value for Nama column”, “rowNum”:“row number from count variable”}.

An example from the database is:

{“number”:“7625”, “nama”:“Jade”, “rowNum”:“4”}

You can instead store the data like this:

value for Number column,value for Nama column,row number from count variable

An example for the above structure is:

7625,Jade,4

Then when trying to change the data (e.g row numbers) you can have another list variable (or repurpose the count variable as a list) to make list from text "j" with delimiter "," and since the data structure is still standardised, to change the data (we’ll continue with the number here) your blocks can look something like (in list "count" get #3) - 1 to change the number locally.

Getting the Data (filtered example)

In this case we are trying to only see users that have a number ending in 6 (Jack in rown number 1, and Jeremy in row number 3) and as you will see below, the data reflected in the list as such. Putting the filter after getting the data allows us to get the data only once and the display is as we see fit, however, the filter must also then be applied to the updateLocalList function when displaying the data.

I initially put the filter when getting the data but noticed that as the filters get more complex, changing the data locally required different function structuring, and we want one way to do it all. This way we can also make many changes and filters locally without having to query the database each time with results being almost instantaneous, the only downside I can see is that the initial fetching of the data may take long if you have a large database (long being a few miliseconds to a second or so).

Deleting Data

Here we repurpose the count variable to get the row number of what needs to be edited/deleted. I focused on deleting here so that we can see how the row number changes and reflects witihin the app and ensure that it is accurate to what is shown in airtable.

The need for temp1 and temp2 list variables is so that we can split the list into the data that is above the row number (e.g if you delete row 5, we need to make sure that the numbers for rows 1 - 4 do not change) and the rest from the new row number (e.g if you delete row 5, row 6 becomes row 5 now and so on) reflect their change to row number - 1. As well as the controls for if rowNum != 1 and so on just in case the first item gets deleted, we may still make the changes and all without affecting the response (e.g if we delete row 1, without the controls we might get an error since the app will try to get the items from position 1 to position 0).

This way, regardless of the order of the data that is diplayed in the list viewer (be it filtered, from bottom to top. etc…) it does not matter what we decide to change as the row number will still be accurate to what is in the database, as well as reflect if something is deleted. Additionally, it will be waaaayyy simpler to make edits to data since now you will always have the correct row number on demand therefore bypassing the complication of thunkable asking for the row number, yet airtable not providing one whether it’s via the SDK or API.

I would just like to stress that the Row ID/Record ID is not the same as the Row Number for your future reference. An example is that the Row Number for Jack is 1, but the Row ID/Record ID for Jack is recuZpQEQQHO7CnUo. That being said, below are results from a delete test I did; The filter was that we should only see uesrs with the last Number as 6, and the list is viewed from bottom to top.

Initial Data and Response
image

Post Delete Data and Response
image

As you can see above, even with data that is filtered in a way that is not representative of the order of the data as well as all the data in airtable, we are still able to remove an item and get the accurate row number(s) for the remaining items without having to call the data from the database.

I hope this helps all who see this! I would suggest you run through the logic and get an understanding of how it works so that you can apply it to all data structures, but you can also post a question here if need be. If someone has a suggestion as well, let us know!

The project link is here, as well as a read only link for the airtable base in case someone wants to copy the data and test it with your own airtable base.

Edits
  1. Spelling and grammar error fixes
  2. Added clarification for JSON storage locally
  3. Added (untested) alternative local storage method coined (CST / Comma Seperated Text)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.