Filter Airtable data shown on cardview based on first column value

Hi guy! So I used @pepocero ‘s ’ How to Get data from Airtable and put it into a CardView

It’s been very helpful thanks!

But now i am trying to filter what a user sees based on the first column value. So that user has a value stored in app and if the first column value matches that value show THAT user THAT row, and any row that ‘belongs to that user’ based on that value.

So only the first 2 rows should show up for that blue user and row 3 and 4 should show up for the red user:

This is the last part of the blocks in the guide and how ive set it up:

How can I implement that sort of filter on the cardview?

Ive played around with:

airtable2

Trying to compare the first row value with the value I have stored in app in ‘info_dni’ text but I can’t seem to figure it out.

Any help?

Thanks!!

You can put a Spinner with the cuit values.

With this you would get in the ListProduct variable all the values that correspond to the cuit you select in a spinner.

If you repeat it for detail and price then you can use it in the cardview

Hi @pepocero thanks a lot for the reply!

The thing is that the ‘cuit’ belongs to a ‘store owner’, and he needs to be able to have access to his products but not be able to see other ‘store owner’s’ products or delete them.

So I can’t have a spinner where anyone can select the cuit number.
I have that cuit for each ‘store owner’ stored in app in ‘info_dni’ text (it pulls it in from firebase on screen initialize), so the idea is to compare the rows cuit with that label and if they match show that ‘store owner’ only his products.

From looking at your explination I think the solution might be around this block:

airtable4

I tried but I can’t seem to make it work.

Any way of doing it or any alternative to this?

Thanks so much!

I’ve been running some tests and if you get all the rows with the “GetAllRows” block, you can do what you need to do.

Now Kodular doesn’t have the JSON component anymore, so you would have to install the JsonTools

Then you would use these blocks:

imagen

The value marked 1 is the cuit. I simulated the cuit is 200 so as not to complicate it with long numbers.
There you should put the number obtained from the texbox (the cuit or dni)

If you are missing any more data (I think the “detalle” is missing) add a “detalle” variable and copy the same as the other addItems, only you have to put the AttributeName=detalle (Remember to write it exactly as the columns in Airtable are called, respecting upper and lower case)

@pepocero thanks so much for your help, for taking to time to test and to show me blocks! Just awesome.

I can’t get it to show in my scroll-arrangement, is there anything i’m missing, any previous steps that I might not be getting right?

Here are my blocks and the whole airtable table. The clock is set to give time for the cuit to load from firebase on to the ‘info_dni’ text on screen initialize:

airtable5

Not sure what i’m missing, thanks so much for your help!

I think you should stop the clock once the rows have been done. At the end of the clock you would have to put a clock enabled to false. If you don’t, that keeps running indefinitely

Thanks for the quick reply!

I put in the timer enable to false block but I’m still not getting anything in my scroll arrangement. Not sure what else to try. :disappointed:

Any other tips?

Thanks!!

@pepocero I’ve tried replacing the dni text with the actual number, just to test:

And I’ve also tried replacing the the timer with a button, also as a test, and I still was not able to get the data to show on my cardview.

Not sure what else to try, any idea?

Thanks a lot for your time!

Put the Response content on a label and see if you get the Json with all the data.

EDIT: Also make sure that the vertical arrangement of the cardview has the width set in the fill parent

Hi @pepocero,

I set the response content to a label to test and I am not getting the values in json format, here are the blocks, all else the same:

I am sure the vertical arrangement of the cardview is set to fill parent, I double checked, and it was getting all of the values, unfiltered, with the previous method.

Not sure what i am doing wrong, I’ve never worked with the json components before.

Thanks for the help!

but there you are not putting the response content, you are using the response code!

2 Likes

Thanks a lot for your help and your time, that did it.

I really can’t thank you enough for your help!

Regards!!

Hi @pepocero thanks a lot for your help. I’ve encountered an issue when trying to delete rows from the cardview and the airtable table.

For example when I want to delete the first row in the USER cardview I use ‘get position’. But instead of deleting that row and card it will delete the first row in the airtable table, even if the USER first row is not the table first row (eliminar is delete):

Here it deletes the row in blue and not the row in red (the red row is the users first row, but 4th row in the table):

And there is another issue, when I press delete (eliminar) in the cardview, it deletes a row in the airtable table but the cardview not only does not change, but multiplies the cardview in the app. (so the three items become 6, and if I press delete again they become 9 and so on). When I exit the app and come back in the reapeted items dissapear.

Here are the blocks:

AIRTABLE11

If you could help it would be great!

You have to keep in mind that with Airtable, you always have to get the data and then work with it. If you delete something, you have to reload the data again (do another Get All Rows). If you don’t do this, you will have a number of items in a variable list, which will not match the number of products in the airtable (because you have deleted one)

So when you delete, you have to “get all rows” again, and reload the lists into the cardview.

With these blocks, you solve it:

1 Like

However, to remove a product it is best to use a confirmation notice.
I’d do something like this:

The result:

1 Like

Thanks a lot @pepocero that helped fix the duplication of the cards!!

I’m still having this last issue:

When I get the position of the card to delete it, it deletes that position in Airtable.
So like in this image below, when I delete the first item in my card view it deletes the first item in the Airtable table. But since the table holds rows with other users info they don’t match.

Here the users first item in Cardview is actually the 4th item in the Airtable table, when I delete the card it deletes the first row instead of the 4th row:

How can I fix this.

Thanks!

The problem is that if you are using these blocks, you have the search filter and you don’t get the whole column.

imagen

In Airtable you have the whole list and in your app you have only the products of a certain cuit, the positions will never coincide.

1 Like

To make it work, with the cuit filtering, these modifications must be made:

(two variables “allcolumn” and “posiciones” are added)

imagen

1 Like

@pepocero, I really can’t thank you enough for all the help, for taking the time, explaining things and showing me the blocks and everything, you really went above and beyond and you really didn’t have to, but you did!!

Thanks so much!

1 Like

Hi @pepocero I have one very, very last question (if you don’t mind, of course).

I am trying to set the values I get from airtable in labels, but, of course, when I set the labels to the global variables (Json Objects) I get all the values, here for example with prices:

How can I get it to show just the index value like on the listview or cardview?

Thank you!!