0

I am working in node-red program and I use an OPCUA node that returns in the payload an array of objects.

enter image description here

I need to get some variables of the objects, for example, the nodeId of the item; and I try with the next format:

var newMsg = { payload: msg.payload[0].item.nodeId };
return newMsg;

But it does not work.I can see the error "Error: invalid identifierType in NodeId : 2" I tried a lot of formats but I do not find the correct way.

Do you know How I could get the data of the array of objects?

Thanks.

4
  • Here you can see that this error is thrown if the identifierType is not valid. But since you just want to use the program this most likely doesn't help you. You could try to get other values and on earlier levels to see if that isn't working either. Commented Apr 30, 2019 at 14:29
  • If I need to get the value of the array, is the next format correct? Commented Apr 30, 2019 at 16:27
  • msg.payload[0].item.nodeId Commented Apr 30, 2019 at 16:28
  • What version of node-red are you using? Commented May 1, 2019 at 6:28

1 Answer 1

2

With the newer versions of Node-RED (after v0.19 iirc) you can get the path to a value from the debug sidebar by placing the mouse over and clicking on the option that pops up.

enter image description here

The >_ icon copies the path to the object (relative to selection in the debug node, so normally msg.payload). In the example payload[0].foo.

This can be used in a function node as msg.payload[0].foo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.