# How to asign properties to objects correctly

**URL:** <https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, i\_need\_your\_help\
**Created:** [April 25, 2022, 6:45pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090 "2022-04-25T18:45:49Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 6:45pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/1 "2022-04-25T18:45:49Z")

</div>

Hello, and Happy Easter!  
Our app is close to be ready, but there are some things that need to be fixed, quickly.  
The issue lies in storing and using some data in firebase.  
On a previous post, I had some issues with the sign up/sign in, but that’s now working just fine.  
Now, there are … things I need help with:

1. When you first register, the app guides you through a profile setup. Now, what I want is to store all of this data under each user.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/a/ba437e6b75a348269cc63bf07283967638f2d895.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/9/f900afb12ef363ed67d9abe5466a736e326e69a3.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/f/bf5d96cbfeb3ac52925d485aefcfdbe9138a07e7.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/4/84d3be40ad0004fafe5ccbd1a8bfe52c40b62290.png)

Now, the problem is, after registe there’s no such thing as an user id, unlike log in, which I would need so that I could store that info under each user.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/2/02d02dabf328d9d38150653dd13e7afd34ad3005.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/d/4d3686448ea569e17778c69694ac6bc12e52b706.png)

I tried this thing but I don’t know if it’s okay:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/f/8f5d87791662265348d80716d307a63ca561a915.png)

When I try to use the app, the stored data looks like this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/a/4ab7f75debabd399e9721ed7a0b618c8c4691959.png)  
When it should look like this:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/a/2a4a150045b3604e3cd2afdb5c11df9938a20404.png)

How can I make this functional?

1. After the data is stored, it shall be used. One of its most important uses is in creating two “branches” of the app. Is this done correctly here? (edit: yes, it is)  

2. Finally, the most important aspect of this app is sharing a location(also depending on the branches). Basically, one user is gonna send his location, and the other will receive it, alongside an alarm. How can I make it possible, based on their ID?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/a/3a503a407dd3c22b7ada0afea1ce8fa434cd50f5.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/4/a4161741b9efa69bd78b58e3cdab1ae4da5a0a5e.png)

(I did this based on LocTrackerv2 app)

Please, please, help us(it’s a team work for a competition). Thank you so much in advance.  
Here is a link to the app:[Thunkable](https://x.thunkable.com/projectPage/6249a0ec5ce74e0012aeab52)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 25, 2022, 7:25pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/2 "2022-04-25T19:25:06Z")

</div>

In the screenshot above, your `sign in` block has the default values for email and password ([hello@gmail.com](mailto:hello@gmail.com) / hello):

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/c/2ccf065ed356a6d635d4d0a2c0d1d265d070a692.png)

You need to add the email and password values that the user typed in there.

Then, the green `user id` block will have the value you need for Firebase. Just store that in a variable (app variable userID).

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 7:41pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/3 "2022-04-25T19:41:41Z")

</div>

Oops, thank you for noticing this, changed it now. But we still need help on the issues mentioned in the post. Could you please look over the project and help us?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 25, 2022, 8:19pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/4 "2022-04-25T20:19:58Z")

</div>

You asked a lot all at once. So I chose one part to help you with.

What specifically do you need help with now?

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 8:26pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/5 "2022-04-25T20:26:02Z")

</div>

I’m so sorry :(.  
The most important aspect right now is storing the user data correctly in the database.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 25, 2022, 8:57pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/6 "2022-04-25T20:57:56Z")

</div>

What happens when you set cloud variable app variable userID to an object with only text values (no latitude, longitude, etc.)?

Do you have that working? If not, can you save **anything** to Firebase successfully?

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 9:04pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/7 "2022-04-25T21:04:05Z")

</div>

Yes, I can save the latitude,longitude and also the image you upload. I cannot save the branch(“ramura”) though, which is the most important data.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 25, 2022, 9:27pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/8 "2022-04-25T21:27:56Z")

</div>

These buttons don’t add any data to Firebase?

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/8/b8e39aba67c15f2fa232711b05469c5c875aacb4.png)

They should. But they also should replace each other’s data because the path and object names are identical. I would expect to see this after voluntar is clicked:

[userID]/ramura : voluntar

And this after pacient is then clicked:

[userID]/ramura : pacient

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 9:41pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/9 "2022-04-25T21:41:51Z")

</div>

Ok, so what happens now is that I select the data, then it is stored, and then it literally disappears. I don’t get why.

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 9:53pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/10 "2022-04-25T21:53:37Z")

</div>

[![](https://img.youtube.com/vi/89P9VB89PNw/maxresdefault.jpg "not working") ](https://www.youtube.com/watch?v=89P9VB89PNw)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 25, 2022, 10:04pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/11 "2022-04-25T22:04:20Z")

</div>

There must be something else deleting those nodes from Firebase. Check to see that you don’t have any stray blocks assigning values to Firebase paths. Is anyone else you know using the project or a copy of the project that can access Firebase?

If you can’t figure out the cause, start to slow things down. Add wait blocks so that you can watch the Firebase values to see when they change. It helps to do something visual on the screen like change a label’s value right before the wait block so you connect that to what is happening in Firebase. This is the method I use for debugging blocks: [Debugging in Thunkable X (Video)](https://community.thunkable.com/t/debugging-in-thunkable-x-video/849471).

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 25, 2022, 10:13pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/12 "2022-04-25T22:13:28Z")

</div>

Thank you a lot!  
and sorry for bothering you so many times :(.

---

<div class="post-metadata">

**Author:** ![aidkittens](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aidkittens/32/131395_2.png) [@aidkittens](https://community.thunkable.com/u/aidkittens)\
**Post date:** [April 27, 2022, 12:18pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/13 "2022-04-27T12:18:28Z")

</div>

I managed to find out what’s the problem here.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/d/cd927e7484ecfc481e254492bc36bcc12015f64f.png)  
you have to create the object ONE TIME, with empty values, and then asign them as you go on. You cannot “add new fields” as you go on, because that will just get overwritten over the other fields.

Thank you once again for your help!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 27, 2022, 2:43pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/14 "2022-04-27T14:43:35Z")

</div>

I think you can do that with the Set Property of Object block. I haven’t tried it myself but see this:

> [@JSON / Object Tutorial](https://community.thunkable.com/t/json-object-tutorial/1085666/2):
>
> Part 1 Basic JSON Key Ideas JavaScript Object Notation (JSON) is a standard cross platform text format for sharing data JSON is text composed of name-value pairs in the format {name:value} Thunkable blocks allow for the creation, modification, coding, and decoding of JSON data What is JSON? JavaScript Object Notation (JSON) is a standard cross platform text format for sharing data. Since Thunkable is [built on Blockly](https://developers.google.com/blockly) (which started as a graphic JavaScript code generator) it make sense to …

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [July 26, 2022, 2:43pm UTC](https://community.thunkable.com/t/how-to-asign-properties-to-objects-correctly/1848090/15 "2022-07-26T14:43:56Z")

</div>

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