# Scripting - system.opc.readValue - Issue with struct

**URL:** <https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767>\
**Category:** Ignition Early Access\
**Tags:** ignition81\
**Created:** [November 21, 2022, 5:46pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767 "2022-11-21T17:46:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [November 21, 2022, 5:46pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/1 "2022-11-21T17:46:21Z")

</div>

I'm on 8.1.20

Don't know when issue appear, but the script below was working well before and now got issue. We haven't use it since some months, but really need this work again.

The script read an array of object by using system.opc.readValue, ofter that I loop into the readed array to get values.

```auto
	
	opc_info = _Functions.getOPCinfo(value["provider"] + "cell/state_cell")
	opc_server = opc_info["server"]
	opc_path = opc_info["opc_path"] + ".check_event_log_array"
		
	check_event_log_array = system.opc.readValue(opc_server, opc_path).getValue()
	
	for i in range(value["first"], value["first"] + value["count"]):
		index = i % value["capacity"]
		entity = system.util.jsonDecode(str(check_event_log_array[index]))

		alert_level = entity["severity"]
		check_code = entity["code"]
		entity_id = entity["entity_id"]
		caused_by_user = entity["caused_by_user"]
		created_on = entity["created_on"]

```

---

<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:** [November 21, 2022, 6:34pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/2 "2022-11-21T18:34:15Z")

</div>

Posting any _details_ about the issue would be helpful.  
In particular, what error(s) are being thrown, the stacktrace, line numbers being indicated as the problem, etc. Check your gateway logs if you're not sure where to start looking. Also, _where_ are you executing this script?

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [November 21, 2022, 6:37pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/3 "2022-11-21T18:37:41Z")

</div>

When I trie to read the array from system.opc.realValue it return null value

[null, Bad("Bad\_AttributeIdInvalid: The attribute is not supported for the specified Node."), Mon Nov 21 13:36:26 EST 2022 (1669055786610)]

---

<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:** [November 21, 2022, 6:54pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/4 "2022-11-21T18:54:38Z")

</div>

What server is this? What is the NodeId (OPC Item Path)?

> [@luc.martin](#):
>
> Bad\_AttributeIdInvalid

This is coming from the server... it probably means something like you're trying to read a value from an object that isn't a VariableNode.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [November 21, 2022, 7:04pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/5 "2022-11-21T19:04:45Z")

</div>

My variable is an array of object...  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/8/98c87c8235ee64a73c1da949aa44ab3d66acad60.png)

I'm not when it stopped to works exactly but with 8.1.18 and higher it doesn't work anymore

opc\_path =\> nsu=urn:BeckhoffAutomation:Ua:PLC;s=MAIN.cell.state\_cell.check\_event\_log\_array

---

<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:** [November 21, 2022, 7:06pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/6 "2022-11-21T19:06:55Z")

</div>

Navigate to this Node using something like UaExpert and see what its NodeClass and other properties are. Provide a screenshot of the attributes pane while viewing this Node.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [November 21, 2022, 7:11pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/7 "2022-11-21T19:11:25Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c59171177af59cd79bb20f683d7c6359a875dfbf.jpeg)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/6/86039518b4077e58e378602fb0a3116266037929.jpeg)

---

<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:** [November 21, 2022, 7:12pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/8 "2022-11-21T19:12:25Z")

</div>

Ok... so that's an Object.

Your script never could have worked unless somebody changed the server model recently.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [November 21, 2022, 7:36pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/9 "2022-11-21T19:36:52Z")

</div>

Is there a way to read an object with system.opc.readValue ?

---

<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:** [November 21, 2022, 7:38pm UTC](https://forum.inductiveautomation.com/t/scripting-system-opc-readvalue-issue-with-struct/66767/10 "2022-11-21T19:38:35Z")

</div>

No, ObjectNodes don't have a value.

In this case it looks like it's being used to organize references to each of the individual elements. If _those_ are VariableNodes you can read the value of each of them.
