How to set label text from database based on local table value

Summary - What I’m trying to do
My application is a mobile reading application. There are essentially 3 screens for the project: home screen (shows images of the available book covers via DVG), book summary screen (enlarged cover image and text summary of book via DVG), and reader screen (text for the chapter and button to advance to the next chapter). The part I’m having trouble with is how I display the text for each chapter of the book on the reader screen.

Ultimately, I want to save readers progress as a local table for each book they read so the app automatically loads the right chapter when they open the book again. However, right now I’m having trouble getting the chapter text logic to work right. What I’d like it to do is check which chapter the user is on for the story and open the right chapter. If they haven’t made any progress, then to open the first chapter. Then after each time they hit the “Next Chapter” button in the reader it updates the local table to increase the chapter for that particular story.

I’ve done a bunch of searching through the docs and these forums (VLOOKUPS in LocalDB, storing rows as objects, etc.), and I’ve learned enough to feel like I know it is possible, but I haven’t been able to crack the code on how to do it. I believe there is some combination of changing the way I store the data (do I change the table so each chapter has a row and curse through to find the right row that matches the story & the user’s progress setting) to how I actually try to access the data via blocks.

Screens

  1. Home screen - this is a DVG of the book covers and title delivered by airtable data source
  2. Summary screen - when a user selects a book from the home screen they can see an enlarged image of the book cover and a short summary of the book. This is done by passing the rowID of the story and setting a label text with the summary column. A user may then hit the “start reading” button.
  3. Reader screen - when a user selects start reading it is meant to load the last chapter the user was on or the 1st chapter of the book if they hadn’t previously opened the book.

Data Sources

  1. Airtable - this contains all the book information and there is a row for each book (title, cover image, summary, and a column for each chapter text). I think I may need to change this to separate tables, but I’m not sure.
  2. Local table - this contains a column for the title of each book and the chapter progress they’ve made, with the default progress set to chapter 1.

This is my first post so happy to provide more information if I’ve missed something. I’d share the project but it’s a private project.

It’s helpful if you can share a screenshot of the blocks you’re having trouble with. Sometimes a small tweak is all that’s needed to fix a problem.

Here is a version of blocks where I started, but couldn’t figure out how to make the logic work. Effectively what I was trying to do was get the chapter text from the row where the story titles matched in the airtable database and the user table. However, I couldn’t find a block that could effectively do a “where” clause. If I could get that to work I was then going to add more blocks to get the chapter that matched the users progress, but I couldn’t get that far.

I think there is a way in which I can use this VLOOKUP style query based on the post here. However, I always get lost in building blocks that become nonsense when trying to adjust the tutorial for my needs so I don’t know.

If you’re using Airtable, I prefer their API’s filterByFormula command described here: Airtable Web API - Using filterByFormula or sort parameters. There’s an example of using it with Thunkable here: The AirTable API (a more efficient way to integrate AirTable with Thunkable) - #22 by jared.

It gives you powerful control over what data you retrieve from Airtable based on multiple conditions.

But if you do need to do this with Thunkable blocks without accessing the API, you need to make sure that your row id values are valid. Row ids are long (hidden) character strings like “A$DN8762!M90KW%” or they can be integers representing the row number in a data source. But attaching a list of values as a row id is surely not going to work.

The summary you provided sounds like a complicated set of steps would be required. It’s certainly possible to do with Thunkable but it’s beyond what I can offer here on the forums. You might consider reaching out to Thunkable Support if you have a Pro or better license or hiring someone to help with this.

Well the two pieces of good news are (1) at least I didn’t miss a simple solution; and (2) you’ve given me some great next steps. Thank you so much for your help! I’ll dig into the resources you provided.

1 Like

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