Getting a record based on a condition from an AppGyver DB

Hello

Thank you well in advance for taking the time to have a look at this.

I am trying to learn appgyver and by far databases are the thing that are confusing me.

I have a sports app that on the home page will bring in the venue of the next game

This element does somewhat work, it gets the collection of records from my database on airtable and brings in the venue. The only thing that I can’t get my head around, when I get single record data from airtable to get venue

it will get the top record because for example: data.GamesDB1[0].id

How do I make it so that it grabs the id from airtable IF my record’s “Status” column = “Next” and not “Upcoming” or “Finished”.

I hope that makes sense, thank you for any insight.

James

There is a parameter called ‘filterByFormula’ that would enable you to limit the data from the API based on a column’s value OR I believe you can also filter the entire data set using a formula when you pass it into the list. I’d go with option 2.

Something like…

https://api.airtable.com/v0/appnDgVtOF7YZEkqZ/{YourAirTableName}?filterByFormula={Status}=“Next”

OR

SELECT(data.GamesDB1,item.status==“Next”)

EDIT:

I may have read your question incorrectly. If you’re just grabbing a single record then I would filter via the API using that filterByFormula parameter.

Thanks Adam

I have seen your edit, I like that option and tried it, I may be very dumb or just misinterpreting it, but when I try to modify the Data Source in appgyver and put the following:
image

I get this error when I run the test?

Maybe I am doing it wrong, I am putting this inside the Get Collection, should I be doing it in Get Record, or should I not be in the Data Source area anyway. I you could explain I would be thankful as I am trying more to learn it than achieve it.

It’s not just you haha. I struggled with that part because it’s not very intuitive. I actually ended going with a different backend because I didn’t like the Airtable API.

It could be that the encoding isn’t correct.

Try filterByFormula=%7BStatus%7D%3D%22Next%22

I used their encoding tool to generate that. Airtable API Encoder (codepen.io)

I believe you could Get Collection or Get Record, but if you use Get Record you would need to make sure it only returned one record. Seems obvious but the API I was using always returned an array until I specified for it to only return one object. Get Collection should work fine if you just specify you want the first object in the array and you know it’s always going to be an array with one object.

1 Like

Brilliant, this works great now, thank you for explaining the difference too - I have to admit, airtable seems confusing, but its the first free one I found so I am trying to stick by it!

Glad to hear it worked! Yeah, it’s definitely a good option since their free tier is very generous. Good luck with the rest of it!