# Question about using Any Component to create new components and saving them to a Database

**URL:** https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216
**Category:** Questions about Thunkable X
**Created:** [January 2, 2020, 3:47pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216 "2020-01-02T15:47:01Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 2, 2020, 3:47pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/1 "2020-01-02T15:47:01Z")

</div>

There seems to be a bug in this platform when you use the “Any Component / Switch” blocks.  
If you use (Component) this to minimize the number of blocks needed in your app, The data written to a Realtime DB is shown as a long string of numbers and letters. If you specify the specific switch you are changing, the data is written as the switch name (i.e. Switch1, Switch2, Switch3).  
The issue is, if you use “Component” instead of the “switch name” (i.e. Switch1), you cannot put the data from the database and display the switch value when the app opens. Your switch value will be grey and off. Use the switch name and the value of the switch is displayed correctly. Can the code of this component be modified to write the component name instead of the long string of numbers and letters? This would solve a big problem. See the screen prints below.

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

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

![image|690x367](upload://tR6meMg6RA4K3y

xyzCzl0WtuGWg.png)

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

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 2, 2020, 3:48pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/2 "2020-01-02T15:48:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)
#### Post date: [January 2, 2020, 7:41pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/3 "2020-01-02T19:41:48Z")

</div>

I solved this problem using Button or switch Text , Simply add a text to the button you need to use and hide the text if You don’t want to be shown. the when any component used don’t use the button name, use the button component get text.

 ![Untitled](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/4/6427a95ea62244ca71cacd49f1f726bf964c7e18.png)

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 2, 2020, 8:21pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/4 "2020-01-02T20:21:08Z")

</div>

Thanks. this would work on the phone. However, I need to be able to make a change to the way the value is saved in a realtime DB. I need to be able to change the output label of the Component to the switch name, not the long running list it produces now. so, instaed of it reading this in the database

17273-374ddc-3783784-fdfd-44858  
switch  
true

I need it to say  
Switch1  
true

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 2, 2020, 8:21pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/5 "2020-01-02T20:21:33Z")

</div>

This is what I get

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

---

<div class="post-metadata">

### Author: ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)
#### Post date: [January 2, 2020, 9:19pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/6 "2020-01-02T21:19:04Z")

</div>

Use all available options amigo 😉

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

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [January 3, 2020, 7:38am UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/7 "2020-01-03T07:38:00Z")

</div>

It is necessary for the component to manually create a new Name property and use it to write it to the database and read from the database instead of the component identifier.

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 3, 2020, 5:15pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/8 "2020-01-03T17:15:02Z")

</div>

I did that. That is what the variable Switches selected does. I also created a new object to see if that would help. As you can see, it writes to the database with the switch name selected in the variable. However, it still will not pull the data and assign it to the right switch.

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

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

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [January 3, 2020, 6:10pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/9 "2020-01-03T18:10:03Z")

</div>

> [@bobbyj12](#):
>
> There seems to be a bug in this platform when you use the “Any Component / Switch” blocks

Hey @bobbyj12,

Just to let you know that this is actually the expected behaviour (and not limited to Switches either!) so I’ve edited the title of this post since it’s not really a bug.

The string of characters you see is actually the unique ID of the component. You can see some more examples of these in the address bar of your browser when you click on different components.

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [January 3, 2020, 6:44pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/10 "2020-01-03T18:44:08Z")

</div>

I don’t see any blocks for creating a new property, so your example can’t possibly implement what I suggested.

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 3, 2020, 7:43pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/11 "2020-01-03T19:43:58Z")

</div>

The if/then statement in the Switch change says, if sw\_1 selected, set variable to sw1. This actually writes “sw1” and the switch value. If you look at the screenshot of the DB, does it look ok? I would think I should use this info to write the values to the switches in my app. I just need to figure out what I need to input into the Key field of the get statement. It pulls the data into the switches but only the last entry into the database.

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [January 4, 2020, 1:28am UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/12 "2020-01-04T01:28:54Z")

</div>

here’s an example of this working with cloud variables now:

> [@Where does Thunkable Live belong in your development workflow?](http://community.thunkable.com/t/where-does-thunkable-live-belong-in-your-development-workflow/390641):
>
> Thunkable Live is a super useful tool to speed up your app development cycle. Like any tool, there are some things it’s really good at, but you can’t use it for everything. Here’s my take on where Thunkable Live fits into a typical app development life cycle, followed by a more in-depth comparison. Sketching Prototyping Thunkable Live Emulator Installing Sketching Whether your using pen and paper or you have a whiteboard and some dry erase markers, there’s really no substitute for…

There are a small few improvements to make in terms of UX, but if a switch is toggled on one device, that same switch will toggle on every device.

Hope that helps!

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [January 4, 2020, 12:19pm UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/13 "2020-01-04T12:19:03Z")

</div>

Thanks for the reply @domhnall. Looking at my blocks, where am I doing wrong not being able to show the value of each block when the app opens?

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 11:46am UTC](https://community.thunkable.com/t/question-about-using-any-component-to-create-new-components-and-saving-them-to-a-database/389216/14 "2024-11-08T11:46:08Z")

</div>


