# Global Variable - Project Script Object has no Attribute

**URL:** <https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [January 10, 2024, 5:58pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061 "2024-01-10T17:58:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 10, 2024, 5:58pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/1 "2024-01-10T17:58:08Z")

</div>

I've got a project script that is having trouble accessing one of it's global variables.

```auto
ignitionName = '/ignition-desktop-av4v6h5:'

def historyPathConvert_MasterToEdge(self):
		
	#if this is an edge panel the path needs to be updated
	if self.parent.parent.edge:
		#get the current pens dataset
		penData = system.dataset.toPyDataSet(self.tagPens)
		
		#get headers for the dataset
		headers = list(penData.getColumnNames())
		
		#initialize empty list
		newPenData = []
		
		#get the index for the tag path column
		TAG_PATH_index = penData.getColumnIndex('TAG_PATH')
		
		#for each row in the pen dataset
		for row in penData:
			#create row as a list
			newRow = list(row)
			
			#update the tag path to the tag provider
			newRow[TAG_PATH_index] = row[TAG_PATH_index].replace(Trending.ignitionName,'/')
			
			#append the row to the list
			newPenData.append(newRow)
		
		#create dataset from list and assign to dataset
		data = system.dataset.toDataSet(headers, newPenData)
		if data is not None:
			self.tagPens = data

```

This script comes back with an error on line 27 when I try and do the string replacement with the pre-defined global string. It's acting like the global variable doesn't exist, even though it auto-completes

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/1849ef890f5e563a0f57a37606ed5631ef575194.png)

```auto
Traceback (most recent call last):
  File "<event:actionPerformed>", line 1, in <module>
  File "<custom-function updatePaths>", line 7, in updatePaths
  File "<module:Trending>", line 27, in historyPathConvert_MasterToEdge
AttributeError: 'com.inductiveautomation.ignition.common.script.Pro' object has no attribute 'ignitionName'

	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._pyx292.historyPathConvert_MasterToEdge$1(<module:Trending>:35)
	at org.python.pycode._pyx292.call_function(<module:Trending>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
	at org.python.core.PyFunction. __call__ (PyFunction.java:416)
	at org.python.pycode._pyx294.updatePaths$1(<custom-function updatePaths>:7)
	at org.python.pycode._pyx294.call_function(<custom-function updatePaths>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
	at org.python.core.PyFunction. __call__ (PyFunction.java:416)
	at org.python.core.PyMethod. __call__ (PyMethod.java:126)
	at org.python.pycode._pyx293.f$0(<event:actionPerformed>:1)
	at org.python.pycode._pyx293.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:803)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:207)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:300)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy52.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.focusLost(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.focusLost(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.focusLost(Unknown Source)
	at java.desktop/java.awt.Component.processFocusEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
	at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
	at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.KeyboardFocusManager.dispatchAndCatchException(Unknown Source)
	at java.desktop/java.awt.KeyboardFocusManager.processCurrentLightweightRequests(Unknown Source)
	at java.desktop/java.awt.KeyboardFocusManager$4.run(Unknown Source)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Ignition v8.1.27 (b2023042509)
Java: Azul Systems, Inc. 11.0.18

```

What am I missing?

---

<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 10, 2024, 5:59pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/2 "2024-01-10T17:59:38Z")

</div>

Why are you referring to it as `Trending.ignitionName` in your script if it's locally defined? Just remove the qualification, and refer to it as `ignitionName`?

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 10, 2024, 5:59pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/3 "2024-01-10T17:59:49Z")

</div>

Same error. Just doing it for verbosity

---

<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 10, 2024, 6:02pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/4 "2024-01-10T18:02:03Z")

</div>

Indentation?  
Posted here it's all indented with spaces, but is that actually how it's all formatted in your file? You can right click and 'Show Whitespace', or paste it into a good external code editor.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 10, 2024, 6:15pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/5 "2024-01-10T18:15:28Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/f/4f4600feddac7dd2bfc1462a674f4d872e8c23f9.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:** [January 10, 2024, 6:30pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/6 "2024-01-10T18:30:31Z")

</div>

I don't really know what's going wrong.  
It works on a test 8.1.35 system, using a mock object for `self`:

```auto
class TestObject(object):
	def __init__ (self):
		self.tagPens = system.dataset.toDataSet(['TAG_PATH'], [["/ignition-desktop-av4v6h5:abc"], ["def"]])
		self.edge = True

t = TestObject()
Trending.historyPathConvert_MasterToEdge(t)

pds = system.dataset.toPyDataSet(t.tagPens)
for row in pds:
	for col in row:
		print col

```

Restart your designer, restart your gateway? Not very satisfying answers...

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 10, 2024, 7:06pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/7 "2024-01-10T19:06:30Z")

</div>

Doesn't make sense to me either since I have other project scripts with global variables that are working

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 10, 2024, 7:18pm UTC](https://forum.inductiveautomation.com/t/global-variable-project-script-object-has-no-attribute/84061/8 "2024-01-10T19:18:16Z")

</div>

Restarted designer and gateway. Not sure which one of those 2 did the trick, but it's working now.
