# Weird behavior when accessing tag data via readBlocking

**URL:** <https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 5, 2025, 3:25pm UTC](https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088 "2025-06-05T15:25:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noah\_Gilgo](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@Noah\_Gilgo](https://forum.inductiveautomation.com/u/Noah_Gilgo)\
**Post date:** [June 5, 2025, 3:25pm UTC](https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088/1 "2025-06-05T15:25:34Z")

</div>

I'm trying to use `system.tag.readBlocking` to access a dataset at a given tag path. However, my transform script is behaving oddly when I try to access the data. Specifically: Python treats my `line_states` variable like a Dataset object _only_ in return statements. Otherwise, when I try to perform typical database operations on the `line_states` variable, I get errors treating it like a `NoneType` object.

```python
def transform(self, value, quality, timestamp):
	item = {
  		"id": "",
  		"label": "New Item",
 		"iconConfig": {
    		"path": "",
    		"color": "",
    		"style": {}
  		},
  		"headerStyle": {
    		"classes": ""
  		},
  		"rowStyle": {
    		"classes": ""
  		}
	}
	
	items = []
	
	for line in value:
		item["id"] = line["value"]
		item["label"] = line["label"]
		
		line_states_qualified_value = system.tag.readBlocking(str(line["EquipmentPath"]) + "/config/stateDS")[0]
		line_states = line_states_qualified_value.value
		state_code_qualified_value = system.tag.readBlocking(str(line["EquipmentPath"]) + "/OEE_Events/state")[0]
		state_code = state_code_qualified_value.value
		state_data = []
		
		line_states_row_count = line_states.getRowCount()
		return line_states_row_count
		
		if line_states_row_count > 0 and state_code:
			for i in range(line_states_row_count):
				if int(line_states.getValueAt(i, "ReasonCode")) == int(state_code):
					line_states_column_count = line_states.getColumnCount()
					for j in range(line_states_column_count):
						states_data.append(line_states.getValueAt(i, j))
					item["iconConfig"]["path"] = line_states.getValueAt()
					item["iconConfig"]["color"] = ""
					item["iconConfig"]["style"] = ""
		
		items.append(item.copy())
	
	return items

```

For example, the code above returns `28` because of the `return line_states_row_count` line. However, if said line is removed, the preceding line `line_states_row_count = line_states.getRowCount()` generates the following error:

`'NoneType' object has no attribute 'getRowCount'`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 5, 2025, 3:30pm UTC](https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088/2 "2025-06-05T15:30:01Z")

</div>

Maybe because removing the early return causes you to iterate through the entire `value` sequence, and eventually you end up with a `line` that results in None after this:

```python
		line_states_qualified_value = system.tag.readBlocking(str(line["EquipmentPath"]) + "/config/stateDS")[0]
		line_states = line_states_qualified_value.value

```

add some print statements to debug.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 5, 2025, 4:16pm UTC](https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088/3 "2025-06-05T16:16:00Z")

</div>

Also, for optimization, you should have 2 loops. One for building a list of all the tags you need to read, then doing a single `system.tag.readBlocking`statement to read them in a single call. Then use those results as part of your iteration on the second loop with something like `for i, line in enumerate(value):` to pull the index and reference the 2 values using `tagValues[i*2].value` and `tagValues[i*2+1].value` for `line_states` and `state_data` respectively.

---

<div class="post-metadata">

**Author:** ![Noah\_Gilgo](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@Noah\_Gilgo](https://forum.inductiveautomation.com/u/Noah_Gilgo)\
**Post date:** [June 5, 2025, 5:07pm UTC](https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088/4 "2025-06-05T17:07:26Z")

</div>

If that's the case, what change would you recommend adding to my code?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 5, 2025, 5:11pm UTC](https://forum.inductiveautomation.com/t/weird-behavior-when-accessing-tag-data-via-readblocking/107088/5 "2025-06-05T17:11:11Z")

</div>

> [@Noah\_Gilgo](#):
>
> If that's the case, what change would you recommend adding to my code?

> [@Kevin.Herron](#):
>
> add some print statements to debug.

Add print statements to print the equipment path of the item, so you can Identify which one is returning a null value for its line states. Last one to be printed before the error is the one with the issue.
