# Duplicate a View with a script

**URL:** <https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 27, 2022, 9:02am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229 "2022-06-27T09:02:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 9:02am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/1 "2022-06-27T09:02:25Z")

</div>

Hi,  
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,

Carla

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 27, 2022, 9:31am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/2 "2022-06-27T09:31:47Z")

</div>

What are you trying to do here?

---

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 9:45am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/3 "2022-06-27T09:45:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 27, 2022, 9:53am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/4 "2022-06-27T09:53:05Z")

</div>

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:  
[https://docs.inductiveautomation.com/display/DOC81/Pages+in+Perspective#PagesinPerspective-PassingParameters(URLParameters)](https://docs.inductiveautomation.com/display/DOC81/Pages+in+Perspective#PagesinPerspective-PassingParameters(URLParameters))

---

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 9:57am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/5 "2022-06-27T09:57:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 27, 2022, 9:58am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/6 "2022-06-27T09:58:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 10:02am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/7 "2022-06-27T10:02:09Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bb68321fb52128f6f32b30b458b77e981395a090.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 27, 2022, 10:04am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/8 "2022-06-27T10:04:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 10:09am UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/9 "2022-06-27T10:09:20Z")

</div>

Ok I’ll try that, thanks.

---

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 1:20pm UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/10 "2022-06-27T13:20:23Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 27, 2022, 1:30pm UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/11 "2022-06-27T13:30:39Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![Carla\_Ratto](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Carla\_Ratto](https://forum.inductiveautomation.com/u/Carla_Ratto)\
**Post date:** [June 27, 2022, 1:48pm UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/12 "2022-06-27T13:48:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 27, 2022, 1:52pm UTC](https://forum.inductiveautomation.com/t/duplicate-a-view-with-a-script/61229/13 "2022-06-27T13:52:36Z")

</div>

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.
