Problem getting value from Firebase that originates from text input

Hi there,

I am having trouble performing something that sounds easy enough and I’ve done it before in a similar way. But in this case I am completely lost:
On one screen, I have a text input field with a number keyboard. The moment the user hits a “save” button next to the field, I am sending the text input as a value to firebase. That works fine.
Example: User types 55 in the field, it populates in Firebase as “55” (within the quotation marks actually).

Now, on another screen I would like to get that value from firebase and change a text label to this value. Things got slightly more complex because a part of the json path to the value (*don’t know correct wording) shall be retrieved through a Local_DB, which shouldn’t be a problem. The blocks shown in the image below are not making it work, and I really don’t understand why. All other blocks showing in the screen are working fine. This is what it looks like:

Here are a few things I tried while playing around in the hopes to figure out what the problem is:

And last but not least, here is a similar thing I am doing in a different part of the app which works like a charm. Somehow, I can’t see what’s different there:

The only difference in my eyes is the origin of the value, which, in the case that doesn’t work, is a text input field.

I’m really hoping someone has an idea what it is. Maybe I’m missing something.

Thank you :slight_smile:
Antje

A few thought to consider.

The Firebase GET Blocks are asynchronous calls and have all sort of brittle behaviors. Consider using the CLOUD scope variables to access Firebase Realtime database. Here is a link to a discussion of the issue
How can i pull all data in firebase to list in thunkable?. You can also DM me if you want to talk about specifics. Even if your app didn’t create the Firebase database, you can use cloud variables to access the data. It is a game changer.

The Realtime DB Get calls as asynchronous.causing all sorts of issues. I JUST finished figuring out a way to convert asynchronous calls to Synchronous functions. It might help reduce some timing issues
How can i pull all data in firebase to list in thunkable?.

Happy Thunking!

3 Likes

Hi there! Thank you so much for your reply. That was extremely helpful to make sense of what is happening!
I didn’t know about the asynchronism of the Realtime DB Get calls.
That hint helped me figure out (ok let’s say I’m 99% sure) that the issue in my specific case is that the Clone function I am performing after the Firebase Get call happens before Firebase even responded with the value and therefore it never had a chance to populate.

For verifying this assumption, I added a Get request to the very end of all other blocks and ‘lo and behold’, that way I was able to show it in a label that sits inside my “prototype” which I am using to create some clones from:

This already made me pretty happy because now I don’t need to get headaches over it any more :smile:
That being said though, I’m going to look into functions and see if I can make use of them for my example before wrapping my mind around the CLOUD variable solution you are suggesting.
I haven’t really worked with functions before, so it might take a while, but I will update here if I was able to figure it out that way or via the CLOUD variable suggestion.

Thank you!
Antje

This function now did the trick now :slight_smile:
Happy about any opinions whether this is a good solution or not.
For now it seems to work perfectly.

2 Likes