How many times a Firebasedb.GotValue can be used in blocks

89 views
Skip to first unread message

Rashid

unread,
Dec 25, 2019, 12:57:07 PM12/25/19
to MIT App Inventor Forum
I am facing problems while retrieving the data from Firebase. Beacuse Got values can be used only with getvalue and G. Is there ot Value event can be used only once the same is with the get list also. Is there any workaround?

ABG

unread,
Dec 25, 2019, 4:00:56 PM12/25/19
to MIT App Inventor Forum
Have you studied FireBase Data Design yet?
Does it answer your question?
ABG

ABG

unread,
Dec 25, 2019, 4:02:35 PM12/25/19
to MIT App Inventor Forum
Also, have you seen the FireBase section of FAQ
?

ABG

unread,
Dec 25, 2019, 5:27:03 PM12/25/19
to MIT App Inventor Forum
I'm not sure what exactly you were asking, and no one else seems around to answer, so here's an answer to a commonly asked question:

If you get only one .Gotvalue event block per FireBaseDB component, how do you
decide what the data is and how to deal with it?

The answer (just tested by me) is to make extra copies of your
FireBaseDB component with the same attributes, but different
component names to remind you which piece(s) of data and which contexts they handle.

In the attached example, I used separate components for customer email and customer
phone requests (a very small grained choice, I admit) with extended tags built up with JOINs
to keep the data separate in the database.

Notice how I request both email and phone in the last button, and
their arriving values magically are handled separately by different event blocks.

If I were working with only one FireBaseDB component, I would have had to add
extra blocks in the .GotData event to examine the incoming tag and route the value
to the proper GUI .Text field.

Another note about tag design:
Using '/' in a tag breaks the tag list off at the first / level.
So keep your customer list separately, and don't
expect to gather it from a taglist.

Other designs might change the bucket on the fly, but I am not experienced in that.

Does this answer your question?

ABG


when fdbCustEmail GotValue.png
when btnCustEmail Click.png
when fdbCustPhone GotValue.png
when btnGetCustPhone Click.png
blocks.png
Capture ABG email and phone.PNG
Capture Rashid email.PNG
Designer components.PNG
when btnGetEmailAndPhone Click.png

TimAI2

unread,
Dec 25, 2019, 5:38:08 PM12/25/19
to MIT App Inventor Forum
Use an if/else if block and test for the tag

Rashid

unread,
Dec 30, 2019, 1:04:49 PM12/30/19
to MIT App Inventor Forum
Thanks. 

Rashid

unread,
Dec 30, 2019, 1:26:34 PM12/30/19
to MIT App Inventor Forum
How?
I have four tags duedate, subject, task and status each have a value input by an user (a teacher) Example values are 10-01-2020, Social Studies  Task Description, Pending.
In data design these value tag pair are under the parent Assignments.

My App has an objective that whenever students logins, he is moved to student screen where he can saw the list of assignment given to him and when he clicks each item in the list (spinner). The tags and corresponding values for the assignment is displayed on the screen. But even though it is displaying the values, it is running a runtime error.



Lable9displays all the data clearly but other lables does not.

TimAI2

unread,
Dec 30, 2019, 1:44:42 PM12/30/19
to MIT App Inventor Forum
This one is about data structure as much as anything else.

1. How do you identify the student, by their mobile phone number only, no name ?
2. Why not store all their (the student) data in one record, one tag, then you can call all of this back as a list ?
3. You haven't used the if/else blocks to define what to do when a tag is called

If you can provide all the fields for a student/students that would go into their records, I will see if I can work up an example for you.

So far I have:

["mobile",["date","subject","task","status"]]

ABG

unread,
Dec 30, 2019, 1:47:32 PM12/30/19
to MIT App Inventor Forum
Do you read what you code?

Auto Generated Inline Image 2.png

TimAI2

unread,
Dec 31, 2019, 4:39:21 AM12/31/19
to MIT App Inventor Forum
@ Rashid

To actually answer your question; "How to call multiple values from Firebase" - see blocks image

blocksFBGetValues.png


TimAI2

unread,
Dec 31, 2019, 10:02:16 AM12/31/19
to MIT App Inventor Forum
We are moving!
For future questions please sign up and use the new community here:
Closing....
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages