# "system" functions not available from client

**URL:** <https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021>\
**Category:** Ignition\
**Created:** [September 5, 2019, 12:25am UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021 "2019-09-05T00:25:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lane.duncan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lane.duncan/32/83700_2.png) [@lane.duncan](https://forum.inductiveautomation.com/u/lane.duncan)\
**Post date:** [September 5, 2019, 12:25am UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/1 "2019-09-05T00:25:53Z")

</div>

I have a template with a custom script, then several instances of that template in a popup window. If I test the popup window in Preview mode from the designer everything work perfectly. As soon as I try to run the script from the client all the system.\* functions throw an error, such as system.gui.messageBox and system.tag.read.

When running from the client I get an error of Object has no attribute 'gui' or 'tag' depending on which system function I call first (I've switched the execution order several times).

Is there a problem accessing system functions from the client? I'm really at a loss.

As I'm writing this the following topic appeared as a suggestion and states this was a bug in the past:

> [@Using system.\* inside a custom function?](http://forum.inductiveautomation.com/t/using-system-inside-a-custom-function/12355/9):
>
> Inductive have confirmed that this is a bug (ticket #44974). Custom functions on windows cannot access project/system or import anything. The workaround is to move the custom function to a component. The best option is to move them to the Root Container. I would strongly advise against using multiple invokeLater calls to fix this, as this is likely to be unreliable.

Is this still a bug?

Thanks,

Lane

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [September 5, 2019, 12:44am UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/2 "2019-09-05T00:44:09Z")

</div>

So, Custom Script on a Vision Template, you have an instance of the Vision Template on a Vision Window, and attempting to triggering the custom script from the window causes the error? If so, then I’m unable to replicate (using 8.0.5 nightly at the moment). What version of Ignition are you using?

Also, it might be helpful to show us the script you’re using, the full error, screenshots, etc.

---

<div class="post-metadata">

**Author:** ![lane.duncan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lane.duncan/32/83700_2.png) [@lane.duncan](https://forum.inductiveautomation.com/u/lane.duncan)\
**Post date:** [September 5, 2019, 12:51pm UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/3 "2019-09-05T12:51:25Z")

</div>

Paul,

Thank you for your fast reply. After a good nights sleep I decided to see if I could duplicate the problem with a new template and a new popup window.

1. Created a template with a label and button, put a custom method at the highest level in the template (window level??):

def TestCustomMethod(self):  
system.gui.messageBox(‘This is the test method’)

1. Created a popup window  
2a. Placed an instance of the template in the window  
2b. Put a custom property in the Root Container called page\_number type integer  
2c. Put a spinner in and linked it to the page\_number property to change the integer value  
2d. Created a property change script in the Root Container to call the custom method in the template when page\_number changes:

if event.propertyName == ‘page\_number’:  
component\_string = ‘TestTemplate’  
event.source.getComponent(component\_string).TestCustomMethod()

1. At this point I pop the window up from my main screen in my Vision Client and everything works as expected (much to my surprise), no errors.

2. I also need to run the method when the window opens, so I add a nearly identical script to the visionWindowOpened event on the popup window:

component\_string = ‘TestTemplate’  
event.source.rootContainer.getComponent(component\_string).TestCustomMethod()

The addition of the script to the visionWindowOpened event throws the error on both the window open script AND the property change script. The script that worked before now does not work.

I am using Ignition 8.0.3.

Text of the error message, the template and the popup window is attached.

[Custom\_Event\_Test.zip](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/170910ada11ecd50d27ab0f9bbe734e10c65a080.zip) (8.4 KB)

[gui\_error.txt](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2e216a09a071a3af2d100a8602b13881364e931e.txt) (2.5 KB)

---

<div class="post-metadata">

**Author:** ![lane.duncan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lane.duncan/32/83700_2.png) [@lane.duncan](https://forum.inductiveautomation.com/u/lane.duncan)\
**Post date:** [September 5, 2019, 12:52pm UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/4 "2019-09-05T12:52:59Z")

</div>

BTW - Indentations are correct in the script, the tabs get lost when typing here.

Thanks,

Lane

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [September 5, 2019, 3:31pm UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/5 "2019-09-05T15:31:07Z")

</div>

Thank you for the backup! It helped immensely!

I was able to replicate the problem. It’s interesting that the initial failure causes later executions to fail. That certainly seems like something we want to address.

In the mean time, this appears to be a race condition of sorts. Instead of calling the custom method initially from `visionWindowOpened`, call it from `internalFrameOpened`.

The there’s a brief discussion [on this page](https://docs.inductiveautomation.com/display/DOC80/Vision+-+The+Window+Object) about the order those events (as well as the event description in the script window), but I’m assuming the part about “…before any bindings on the window are evaluated” ties to this case for some reason.

I’ll make a ticket here, but mind trying to call your script from the `internalFrameOpened` event instead?

---

<div class="post-metadata">

**Author:** ![lane.duncan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lane.duncan/32/83700_2.png) [@lane.duncan](https://forum.inductiveautomation.com/u/lane.duncan)\
**Post date:** [September 5, 2019, 5:55pm UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/6 "2019-09-05T17:55:05Z")

</div>

> [@Paul.Scott](#):
>
> from `visionWindowOpened` , call it from `internalFrameOpened` .

A simple cut and paste to internalFrameOpened from visionWindowOpened fixed the issue. I'll have to take a closer look at the order of events in the near future.

Thank you very much for your help!

Lane

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [September 5, 2019, 7:28pm UTC](https://forum.inductiveautomation.com/t/system-functions-not-available-from-client/28021/7 "2019-09-05T19:28:42Z")

</div>

Glad to hear it worked! In your defense, the event order is _far_ from clear based on the description, which is something I’m trying to get changed.
