# 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'active\_call'

**URL:** <https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [July 11, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198 "2023-07-11T15:21:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [July 11, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/1 "2023-07-11T15:21:32Z")

</div>

Hi, I have a valueChanged script on a timer that uses an array custom value that keeps getting the below error. Below is also my script and the custom values it uses, active\_call is dynamic and can have more instances.

```auto
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:valueChanged>", line 3, in valueChanged
AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'active_calls'

	at org.python.core.Py.AttributeError(Py.java:178)
	at org.python.core.PyObject.noAttributeError(PyObject.java:965)
	at org.python.core.PyObject. __getattr__ (PyObject.java:959)
	at org.python.pycode._pyx59055.valueChanged$1(<function:valueChanged>:22)
	at org.python.pycode._pyx59055.call_function(<function:valueChanged>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
	at org.python.core.PyFunction.function ___call__ (PyFunction.java:474)
	at org.python.core.PyFunction. __call__ (PyFunction.java:469)
	at org.python.core.PyFunction. __call__ (PyFunction.java:464)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:846)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:828)
	at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:832)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:1009)
	at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:897)
	at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:147)
	at com.inductiveautomation.perspective.gateway.model.PropertyChangeScript.access$001(PropertyChangeScript.java:30)
	at com.inductiveautomation.perspective.gateway.model.PropertyChangeScript$ScriptSequencer.run(PropertyChangeScript.java:156)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at com.inductiveautomation.perspective.gateway.threading.BlockingWork$BlockingWorkRunnable.run(BlockingWork.java:58)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.python.core.PyException

```

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

---

<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:** [July 11, 2023, 3:40pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/2 "2023-07-11T15:40:37Z")

</div>

Use dictionary access "subscript" syntax (`self.custom['active_calls']`) to refer to properties, rather than named attribute access. The property selector should help you with this.

---

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [July 11, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/3 "2023-07-11T15:57:33Z")

</div>

That seems to let up the error. Do you mean to say I should refer to all properties that way or just the array? The property selector added the values the way they are added in my original code.

---

<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:** [July 11, 2023, 5:18pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/4 "2023-07-11T17:18:22Z")

</div>

Honestly, I work in Perspective so infrequently that I just thought it was wrong. I kinda prefer the string subscript access anyways (since it's more clear to me that you're effectively retrieving items from a dictionary-like object _and_ it has no issues with key escaping), but it's probably the fact that you changed the script at all that fixed it, rather than the specific changes you made.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 11, 2023, 5:22pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/5 "2023-07-11T17:22:13Z")

</div>

might also be another gotcha from this:

```auto
calls = self.custom.active_calls

```

@pbg See this thread:

> [@\[IGN-1660\]PSA - Assigning values to a property in a script may drive you nuts](https://forum.inductiveautomation.com/t/ign-1660-psa-assigning-values-to-a-property-in-a-script-may-drive-you-nuts/76192/4):
>
> Among other things, basically, don't do this. You're capturing the 'property tree' wrapper housed at self.custom.data in your script. Mutations are primarily forwarded to the actual backing store (because that's what matters, and what syncs to the frontend) and there's a longstanding bug where the local instance you have doesn't reflect those updates correctly. It's mostly been a nuisance bug because the typical pattern (referring to component props fully qualified all the time) avoids it.

---

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [July 11, 2023, 5:42pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/6 "2023-07-11T17:42:22Z")

</div>

I think I spoke too soon, now I just get a different error. I mean, the code still runs and there's no errors thrown outside of the designer so maybe I could leave it.

```auto
 File "<function:valueChanged>", line 3, in valueChanged
KeyError: 'active_calls'

```

---

<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:** [July 11, 2023, 5:49pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/7 "2023-07-11T17:49:56Z")

</div>

Any chance there's a trailing space or something else on your key?

---

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [July 11, 2023, 5:55pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/8 "2023-07-11T17:55:55Z")

</div>

No there isn't, to me that error is weird since it still reads whatever is in active\_calls anyways.

---

<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:** [July 11, 2023, 6:05pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/9 "2023-07-11T18:05:40Z")

</div>

Is that property set to persistent? Any chance your event is running before the `active_calls` property is written the first time?

---

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [July 11, 2023, 6:36pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/10 "2023-07-11T18:36:43Z")

</div>

The active\_calls property is continuously getting data from a query tag. The default is always just value in designer unless otherwise specified.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 11, 2023, 6:55pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/11 "2023-07-11T18:55:57Z")

</div>

> [@pbg](#):
>
> The default is always just value in designer unless otherwise specified

Except for when the view is first loaded. If the property change script executes prior to the `active_calls` property being added, you will get a key error.

Try setting the active\_calls property to be persistent, right now it is not, and see if that eliminates your error.

---

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [July 11, 2023, 7:09pm UTC](https://forum.inductiveautomation.com/t/com-inductiveautomation-perspective-gateway-script-object-has-no-attribute-active-call/76198/12 "2023-07-11T19:09:04Z")

</div>

OH, I understand. Did that and so far no errors, thank you!
