Duplicate a View with a script

Is it possible to create or duplicate a view with a script ? I searched for system functions that could help but didn’t find anything.
Also, is there another function to pass parameters to this view ?
Thank you,


What are you trying to do here?

I am creating a view where the administrator can configure a new plant. Then, I first created a button to configure the UDT corresponding to this particular plant (composed of several machines that we can call MachineA and MachineB), and to create the instance of this UDT to retrieve the data. But now that I managed to do this, I need to create the views to display these data. I have some “template views”, and I would like to create the right number of views according to the number of machines the plant possess.

In my first version (1 MachineA and 1 MachineB), I used the dropConfig property so that the instanciation of the “template views” is easier, so if possible I would like to keep this property but maybe it won’t be the better approach now.

if you have almost identical views for these machines you should use viewparams with your template views and not copies.

you can pass viewparams with urls:

But then the user will have to write the parameters value in the URL to see the page on the web browser ?

how do you plan on letting the user navigate to/view MachineA or MachineB ?

For the moment I have a menu on top of the page, and the user can clic on the item he wants to see. I will now have to do an “adaptative” menu so that it displays the right number of items.

then you should be able to include the parameters you need on the navigate button

Ok I’ll try that, thanks.

1 Like

I made some tests, it seems to work but I don’t know if this method is really what I need because I have to pass approximatively 5 parameters to the view, and if I have to pass all of them in the URL it will be a little bit unreadable. I feel like I’m missing something obvious but can’t figure what …

You don’t need to pass them through the url, you can use a view as target of your navigation and pass it the parameters directly.
I’m not sure how that integrates with your menu, but you could always make a custom menu and use system.perspective.navigate.

1 Like

Ok I see. I also found that the HorizontalMenu component has an OnItemClicked event, maybe I can do something using this and the navigate function. I try that.

Yes it should work. You might get errors logged to the console if you remove the builtin target of the menu’s elements, but it should work nonetheless.