# System.Perspective function use within Project Scripts

**URL:** <https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 3, 2022, 6:11pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609 "2022-01-03T18:11:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![agriner](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@agriner](https://forum.inductiveautomation.com/u/agriner)\
**Post date:** [January 3, 2022, 6:11pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609/1 "2022-01-03T18:11:04Z")

</div>

I’ve written a project script and it works fine until it hits a part where I open a popup using the system.perspective script. I’ve noticed intellisense won’t auto-complete system.perspective.  
I’m wondering if that means that it’s not allowed. If that’s the case, is there another way to open an error pop up that a gateway script would allow?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 3, 2022, 6:25pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609/2 "2022-01-03T18:25:50Z")

</div>

The autocompletion within project scripts is the ‘designer’ scope, but that doesn’t mean system.perspective functions won’t work; just that you have to be sure to call them appropriately.

We have a pending ticket to add a dropdown to project scripts to allow you to manually select what scope is appropriate.

---

<div class="post-metadata">

**Author:** ![agriner](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@agriner](https://forum.inductiveautomation.com/u/agriner)\
**Post date:** [January 3, 2022, 6:33pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609/3 "2022-01-03T18:33:56Z")

</div>

Oh okay, I follow. I think my syntax might be off. Is there an additional import I need to do?  
I’m running system.perspective.openPopup(‘Popup’, ‘Page/Error\_PopUp’) from within the project script.  
I’m seeing:  
AttributeError: ‘com.inductiveautomation.ignition.designer.gui.tool’ object has no attribute ‘perspective’

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 3, 2022, 6:43pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609/4 "2022-01-03T18:43:39Z")

</div>

You have to be _calling_ from a Perspective context; the library is just Python code that isn’t really validated (beyond syntax) until it’s called.

How are you invoking this popup action?

If you’re trying to write a generic ‘popup an error’ function _for use in both Vision and Perspective_, that’s doable, but a little more involved.

---

<div class="post-metadata">

**Author:** ![agriner](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@agriner](https://forum.inductiveautomation.com/u/agriner)\
**Post date:** [January 3, 2022, 6:53pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609/5 "2022-01-03T18:53:53Z")

</div>

The project script is triggered using a tag event script (value changed) That tag value changes either with input from a barcode scanner or a text box in a perspective view.  
I have try/catches in the project script and I’m trying to get those to open the error popup whenever something fails.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 3, 2022, 7:04pm UTC](https://forum.inductiveautomation.com/t/system-perspective-function-use-within-project-scripts/54609/6 "2022-01-03T19:04:27Z")

</div>

You’re probably going to have to restructure things a bit.

Basically, once you’re in a tag event script (as in, configured specifically on a tag, rather than a tag _change_ script), you’ve “lost” the context of the Vision or Perspective window/view you were in.

I would recommend a somewhat different pattern.  
Instead of writing to the tag, and _then_ checking for some error condition, you should have your ‘validation’ logic in the project library, and have your barcode scan/text box simply invoke that shared project script. You can use the technique(s) described in [this thread](https://forum.inductiveautomation.com/t/a-universal-way-to-alert-devleopers-about-errors/34914) to throw a generic error back to either context.

That way you can ‘guarantee’ whatever value makes it onto the tag is validated, and simplify the logic in your tag event script (I would also recommend putting _that_ code into a project script, as a general practice).
