"Search for" "Data Type" "last Item" not working

Hey there!

Been trying all day to populate text from a data field into a text box in my app, and it’s just not working as it should. Anyone know why this format for (what should be) a simple data load isn’t working? Here’s a picture of what it is.


The data is loaded to the database from an API, not from a user, and it’s probably 900 characters if that makes a difference.

Appreciate any thoughts, ideas, or help.

Thanks!
Paul

What do you mean it’s not working?

(and what does ‘last item’ have to do with anything here?)

Good questions, Adam. Thanks. Here’s some more context that I should have provided:

The app I’m making uses chatgpt to generate a summary of a PDF document. The summary will later be used for other things, however, it must be displayed to and reviewed by the user before it is, so it is collected and stored in the Bubble database. The summary review screen is a simple dynamic text element that displays the result of the PDF-summarizing api call. That’s it. But the data in that field must also be retained for further use, so it must be stored in the database.

In creating the summary review screen, I used the “Search for” “Data Type” and “Last Item” as it says in the Bubble documentation here (and, as I understand it, is the commonly done procedure as shown in videos like this one. There are loads of them out there, but this was the best for me.).

“Last item” (or sometimes “First Item.” I’ve tried all versions) is the method that seems to be the only way to view the results of that last input of that data type into that particular field in Bubble. (I think everyone agrees it’s a little indirect, but that’s what everyone seems to use.) In demos and ind Bubble documentation, everyone else seems to have success with it. But not me. And I have tried probably 50 or 60 permutations of the process.

One thing I did leave out is that I also pointed the parent group at the correct data type before commanding the text element to search it. Here’s a screenshot of the parent group dynamic text function:

Any thoughts you have would be great.

Thanks so much,
Paul

Just one more thing, Adam. What I mean by “not working” is that the result of all these permutations is a blank dynamic text element. When I preview (hundreds of times) this is what I get:

In some iterations of this process, I get a single comma (“,”) in the preview, but no text. Weird!
(Oh, and a typical summary is about 1,000 characters.)

Have you verified that the data is actually stored in the database?

Also, by using Do a search for … :last item, you are retrieving every single record for that item in the database and then selecting only the last one from the frontend. Depending on your app, I suspect this is not what you want.

First, limit your search to items created by Current User. Then, I’d limit the search to retrieve only the record that you are looking for. Without more knowledge of your app and your database it’s hard to suggest something. But if you have any specific data that can identify which entry to retrieve, you will want to limit the search to that item.

If you are retrieving it immediately after it’s written to the database, it could be a timing error. Try saving it first in a state, then to the database, then populate your text box from the state.

Or perhaps you have a reference to the item after it was saved to the database. You say it’s from an API. Does the API return any values you can use to identify which item it created?

Thanks, Ken and Adam! Turns out it was my privacy settings. I inadvertently locked myself out of my own data display. (Surprisingly easy to do, it turns out.) The “Search for” “Data Type” “Last Item” seems to work now. Thanks so much and have a great week.

BTW, Now that I’ve got the thing to show up, it’s maintaining its JSON coding. so it looks like this:

{“id”:“chatcmpl-8WxTihitIp1gnnaQRLS3tbfRi3akQ”,“object”:“chat.completion”,“created”:1702865822,“model”:“gpt-4-0613”,“choices”:[{“index”:0,“message”:{“role”:“assistant”,“content”:“Introduction:\nThis text focuses on Amazon Connect, a cloud-based, omnichannel contact center tool offered in partnership with [AWS Partner]. Created to help small businesses… etc. etc.”

Any thoughts on how to remove the code and just show the summary text? I’m trying to make the JSON Manipulator plugin work, but having trouble.

Thanks again!