Give Components a Script at runtime

Hey pretty weird question but is it possible to give a component a script at runtime?
I know that I can create a new component with the .addComponent() function but I was wondering if i can assign a script to it at runtime.

Yes, but really far under the hood in the module development SDK. (And not documented there, either.)

The supported way to dynamically add/remove components in Vision is with the Template Repeater and the Template Canvas. Using .addComponent yourself is fraught with complications.

What's your actual use case? What are you trying to do?

1 Like

I want to reiterate this because this is more than likely the solution you are looking for. With this approach, you can set your components up in a template already scripted and already set up exactly how you want. Then, you can add or remove them by simply adding rows to or removing rows from a single dataset parameter. It's simple, and perhaps more importantly, it's easily maintainable by others who will someday have to work on the project.


Yes I will thing about that approach. You actually gave me the information I was missing in another topic (Dynamically getting a Component by clicking on it - Ignition - Inductive Automation Forum) I posted Yesterday so thanks again. I find it really helpful to know how the stuff is handled in the backend.