# Add component with script

**URL:** <https://forum.inductiveautomation.com/t/add-component-with-script/91239>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [June 1, 2024, 2:11pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239 "2024-06-01T14:11:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 2:11pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/1 "2024-06-01T14:11:42Z")

</div>

I have an coordinate container and i want to add a new component (eg label component) with script. Like when a button is pressed a new label component will be added. I have seen this in one project but do not know how to do it.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 1, 2024, 2:19pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/2 "2024-06-01T14:19:46Z")

</div>

No. You could create a parameterised view containing a label and then use a Flex Repeater to increase the number of instances.

Can you describe the real problem you are trying to solve?

---

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/3 "2024-06-01T14:33:04Z")

</div>

I'm just trying to add a new label or text component component on the screen. Something like microsoft notebook.  
Can you explain a bit detail about what you said before

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 1, 2024, 2:37pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/4 "2024-06-01T14:37:06Z")

</div>

> [@Vatsal\_Shah](#):
>
> microsoft notebook.

I can't find any web reference to a "Microsoft Notebook". Do you mean OneNote? If so, then no.

> **[Perspective - Flex Repeater | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-embedding-palette/perspective-flex-repeater)**
>
> The Flex Repeater component lets you easily create multiple instances of views for display in another view.

---

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 2:38pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/5 "2024-06-01T14:38:14Z")

</div>

Yes OneNote  
My Bad.

---

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 2:43pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/6 "2024-06-01T14:43:25Z")

</div>

when the button is clicked a new label component should be added under the root

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25ce5949b6249be0b902affbc2c561ffbb689499.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 1, 2024, 2:44pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/7 "2024-06-01T14:44:27Z")

</div>

What use is that?

Again, can you describe the real problem you are trying to solve? What kind of application are you trying to make?

---

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 2:46pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/8 "2024-06-01T14:46:19Z")

</div>

just trying to add components with script.  
If this thing is achieved then i will move forward to build something

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 1, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/9 "2024-06-01T16:04:02Z")

</div>

Use a flex repeater and add/remove instances as needed.

This is a great example of XY problem.

---

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 4:17pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/10 "2024-06-01T16:17:00Z")

</div>

Flex repeater won't be suffice or useful in this case as every instance will be created at the flex repeater component level. I'm trying to do is to add component at view level.  
If we copy component and paste it in notepad we can see the structure of that component. I was thinking if we can modify some properties like name and property and then append it in the view structure.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 1, 2024, 4:30pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/11 "2024-06-01T16:30:32Z")

</div>

You said you wanted to add a label by clicking a button, no? The flex repeater will work for this. You create a view with a label and with a parameter for text. When you click the button a new instance is created in the flex repeater. You can use a database, tag, or maybe global variable to store these instances if want things to be retentive in nature.

It sounds like you have blinders on and are only interested in someone giving you the answers to what you think the problem is.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2024, 4:37pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/12 "2024-06-01T16:37:50Z")

</div>

> [@Vatsal\_Shah](#):
>
> I'm trying to do is to add component at view level.

There's no mechanism in Ignition that would let you do this. The only thing that could possibly do this is directly modifying the view definition in the gateway filesystem and waiting for the gateway to notice that you did so.

(I would recommend the view canvas instead of the flex repeater to solve your actual problem, but either method provides runtime support for dynamic structure in your view.)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 1, 2024, 5:17pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/13 "2024-06-01T17:17:36Z")

</div>

I think you could use the following instead of waiting for the system to update on its own.

> **[system.project.requestScan | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-project/system-project-requestScan)**
>
> Requests a manual scan of the projects directory in order to refresh projects and their resources.

---

<div class="post-metadata">

**Author:** ![Vatsal\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/0ea827/32.png) [@Vatsal\_Shah](https://forum.inductiveautomation.com/u/Vatsal_Shah)\
**Post date:** [June 1, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/add-component-with-script/91239/14 "2024-06-01T17:56:25Z")

</div>

I created a component - 'Text field' and made it visible on button click.  
At this point I saved the all the required properties of this new TextField in a new memory tag of this  
opened the exiting view.json file modified it and saved it with the different button click script.  
closed the session and then relaunched the session and it was showing the new compoent.  
The only thing was I have to wait for the gateway to update the project.  
I will now make use of requestScan and see
