# Open additional instance of view(popup) in perspective

**URL:** <https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845>\
**Category:** Ignition Early Access\
**Created:** [June 15, 2019, 11:36am UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845 "2019-06-15T11:36:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [June 15, 2019, 11:36am UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/1 "2019-06-15T11:36:30Z")

</div>

How do I open additional instance of view(popup) in perspective? Like additional instance in vision.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 17, 2019, 2:17pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/2 "2019-06-17T14:17:14Z")

</div>

You can open as many instances as you need, as long as each one has a unique id supplied.

Pseudo-code:

```auto
for i in range(4):
    system.perspective.openPopup(id=i, title='Popup #{0}',format(i))

```

Should open four popups. They’ll all be on top of each other since I’ve not provided differing open locations, but if you drag the top one, you’ll see another beneath it.

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [June 17, 2019, 4:28pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/3 "2019-06-17T16:28:43Z")

</div>

The problem of this solution is I can’t track the id number I used before. For example I create embedded view of pump with popup. each time the user click on each pump the popup will open and I have to assign unique id to each ooened popup.  
I wish this handle in perspective like vision In vision I just click multi instance option and vision keep track of assign id.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 17, 2019, 4:40pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/4 "2019-06-17T16:40:19Z")

</div>

You can very easily provide the id of the popup to the View as a parameter.

```auto
for i in range(4):
    system.perspective.openPopup(id=i, title='Popup #{0}',format(i),params={'id':i})

```

Doing this allows the Popup itself to track its id, so that you can also allow for closing the popup from within the popup.

To set up a Popup close action, for example:

1. In the View used for the Popup, create a new property: View.params.id
2. Place some button in the View.
3. Provide anew onClick event for the button which invokes a Popup Action which will close a Popup, and bind the id attribute of this action to `View.params.id`.

From your use-case, it sounds like each pump should have its own unique identifier already ie: “pump\_A”, “pump\_B”. So the specific pump should be able to supply whatever unique identifier was used to create the Embedded View as an id for the Popup.

```auto
my_pump_id = self.view.params.pump_id
system.perspective.openPopup(id=my_pump_id, params={'id':my_pump_id})

```

---

<div class="post-metadata">

**Author:** ![Bojacobsen](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bojacobsen](https://forum.inductiveautomation.com/u/Bojacobsen)\
**Post date:** [February 13, 2020, 4:17pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/5 "2020-02-13T16:17:06Z")

</div>

I just use the TagPath for the tag in template.

set the Identifier to {view.params.TagPath}

Can have as many popup as i want and no need for script.

---

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [April 24, 2020, 5:11pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/6 "2020-04-24T17:11:39Z")

</div>

I don’t understand the reasoning behind passing the id as a parameter, I was under the impression that using the syntax provided in the user manual would assign it a unique ID:

```auto
`# Opens a popup view. We are passing in two parameters, called "myParam" and "myParam2". We also set some additional properties of the popup.`

`system.perspective.openPopup(` `"myPopupId"` `,` `'folder/myView'` `, params ` `=` `{` `'myParam'` `:` `1` `,` `'myParam2'` `:` `'Test'` `}, showCloseIcon ` `=` `False` `, resizable ` `=` `True` `)`

```

I’ve noticed when I try to open two different popups, one from within the other, it closes my first popup.  
They have unique IDs:

```auto
#First Popup Opening:
tagsToTrend = 'sometagPath'
system.perspective.openPopup(id = "north_douglas_tanks",view ='Compressors/North Douglas Tanks',params={'tagsToTrend':tagsToTrend}, resizable = True, draggable = True)'

#Second popup Opening within the first, both with unique IDs:
tagList = 'someArray'
if len(tagList) == 0:
	tagList = self.view.custom.tagsToTrend
	system.perspective.openPopup(id = "CompTrend",view ='Trending/trendView',params={'tagList':tagList}, resizable = True, draggable = True, showCloseIcon=False)
else:
	tagList = self.view.custom.tagsToTrend
	system.perspective.closePopup(id = "CompTrend")
	system.perspective.openPopup(id = "CompTrend", view ='Trending/trendView',params={'tagList':tagList}, resizable = True, draggable = True, showCloseIcon=False)

```

I know in my script there is a closepopup command depending on the size of the array I’m passing into it. But, the popup with the ID ‘north\_douglas\_tanks’ should not be closing even if that condition is met correct?

Also, what does perspective do when you call for a popup to be closed when there is no popup with that ID? Could that somehow be causing it to close my first popup?

Thanks

---

<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:** [April 24, 2020, 5:47pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/7 "2020-04-24T17:47:50Z")

</div>

> [@tmahaffey](#):
>
> Also, what does perspective do when you call for a popup to be closed when there is no popup with that ID? Could that somehow be causing it to close my first popup?

Yes. It closes any random other popup. This was recently fixed, IIRC.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [April 24, 2020, 6:00pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/8 "2020-04-24T18:00:50Z")

</div>

> [@tmahaffey](#):
>
> I was under the impression that using the syntax provided in the user manual would assign it a unique ID:

This is true, but you are not supplied with the ID, so when this thread was initially opened you could not target the popup you just opened with future closePopup invocations (what would you supply for the `id` argument?).

> [@tmahaffey](#):
>
> I’ve noticed when I try to open two different popups, one from within the other, it closes my first popup.  
> They have unique IDs:

I just tested this on a nightly build because that should not be happening, and I did not encounter the issue even while the popups were created as modals.

This screenshot contains two popups - one of which was opened from within a different popup.

 ![12%20AM](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a69e9f5b70275e0928d56d0b50d8807299dcaf98.png)

> [@tmahaffey](#):
>
> Also, what does perspective do when you call for a popup to be closed when there is no popup with that ID? Could that somehow be causing it to close my first popup?

THIS is the crux of your problem. Before the upcoming 8.0.13 release, if Perspective could not locate a Popup with a specified `id`, it would close the most recently focused Popup. This was undesirable, and so we fixed the behavior. I verified it's working as expected in the nightly build. if you take this nightly you should no longer encounter this behavior with one exception: id arguments supplied with empty strings.

We're aware some users would prefer to just close any open Popup without wanting to track the id, so

```auto
system.perspective.closePopup(id='')

```

will close the most recently focused popup in 8.0.13.

---

<div class="post-metadata">

**Author:** ![tmahaffey](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tmahaffey/32/30949_2.png) [@tmahaffey](https://forum.inductiveautomation.com/u/tmahaffey)\
**Post date:** [April 27, 2020, 2:33pm UTC](https://forum.inductiveautomation.com/t/open-additional-instance-of-view-popup-in-perspective/25845/9 "2020-04-27T14:33:07Z")

</div>

Thank you.
