# OPC-UA Method Calls

**URL:** <https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923>\
**Category:** Module Development\
**Created:** [July 12, 2016, 9:56pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923 "2016-07-12T21:56:35Z")\
**Posts on this page:** 8\
**Page:** 2

<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:** [July 1, 2019, 3:13pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/21 "2019-07-01T15:13:05Z")

</div>

Nothing like that is available.

OPC UA does have a service called TranslateBrowsePathsToNodeIds, which if you know the full browse path to the Node in question, can be used to get the NodeId, but there’s no way to get the NodeId from just a Node’s name on its own.

There’s no way for you to call this service from scripting right now though, we’d have to add support for it like we did with `callMethod`.

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [May 15, 2020, 4:52am UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/22 "2020-05-15T04:52:39Z")

</div>

@Kevin.Herron  
Using a service such as TranslateBrowsePathsToNodeIds would help Ignition be more elegant in its scripting to access methods. Hard-coding the NodeId, which includes the namespace id is clunky, and won’t be feasible when trying to access gateway-type devices that aggregate multiple address spaces and assign whatever namespace id it chooses.

What are the next features to be added to the system.opcua family of scripting functions?

Thanks!

---

<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:** [May 15, 2020, 12:16pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/23 "2020-05-15T12:16:06Z")

</div>

It's only a marginal win because browse names are QualifiedNames, which also require a namespace index. So it would end up looking something like this:

```auto
result = system.opcua.callMethod(
    "Ignition OPC UA Server",
    "Obects/3:Path/3:To/3:Node",
    "Obects/3:Path/3:To/3:Node/3:MethodName",
    [1]
)

```

where you'd still be required to know the correct namespace indices of each component in the path...

> [@321liftoff](#):
>
> What are the next features to be added to the system.opcua family of scripting functions?

Nothing solid planned... anything in particular you had in mind?

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [May 16, 2020, 5:07am UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/24 "2020-05-16T05:07:43Z")

</div>

Would it be possible to parse the source of an existing Ignition OPC tag to obtain what the namespace index is? The tag I would poll would be within the same address space as the method.

---

<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:** [May 17, 2020, 2:12pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/25 "2020-05-17T14:12:26Z")

</div>

The OPC Item Path of an OPC Tag from an OPC UA server is a parseable string representation of a NodeId. The “ns=N;” prefix is specifying the namespace index (N).

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [May 26, 2020, 7:53pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/26 "2020-05-26T19:53:32Z")

</div>

@Kevin.Herron Thanks.

For those interested, here’s some code that I used to achieve what Kevin suggested:

```auto
tagPath = "path-to-ignition-tag-in-same-address-space-as-method"
tagConfig = system.tag.getConfiguration(tagPath, False)
server = tagConfig[0]['opcServer']
opcPath = tagConfig[0]['opcItemPath']
#opcValue = system.opc.readValue(server, opcPath).getValue()

namespaceID = opcPath[3:str(opcPath).find(";")]
objectId = 'ns='+namespaceID+';s=id-of-object-containing-the-method'
methodId = 'ns='+namespaceID+';s=id-of-method'
system.opcua.callMethod(server, objectId, methodId,[])

```

---

<div class="post-metadata">

**Author:** ![Ethan\_Bachman](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@Ethan\_Bachman](https://forum.inductiveautomation.com/u/Ethan_Bachman)\
**Post date:** [June 24, 2022, 4:35pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/27 "2022-06-24T16:35:26Z")

</div>

I am using Ignition Edge, and when I attempt to test the system.opcua.callMethod(), I get a message saying that “com.inductiveautomation.ignition.designer.gui.tool’ object has no attribute ‘opcua’.”

Is there a separate library I need to install to use this function?

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [June 24, 2022, 10:01pm UTC](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923/28 "2022-06-24T22:01:07Z")

</div>

system.opcua.callMethod() is scoped for scripting from the Gateway and Perspective Session contexts.

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

[https://docs.inductiveautomation.com/display/DOC81/system.opcua.callMethod](https://docs.inductiveautomation.com/display/DOC81/system.opcua.callMethod)

That means you’ll need to run this either from inside Perspective (as a script on a button click, for example), on a tag script (tag change, for example), or other Gateway scripting places. It’s not designed to run from the Designer scope. (The error indicates you’re trying to run it from the designer.)

[Previous page](https://forum.inductiveautomation.com/t/opc-ua-method-calls/11923.md?page=1)
