Error in payload

What causes the following error and how do I fix it ?

msg : error

"TypeError: Cannot read properties of undefined (reading 'split')"

An undefined property that a script is trying to read another property from, often hard to pin point with no info.

What info would you like to know? I am using .json format as input


            "name" : "Integer001",

            "value" :"1444535466",
            "type" : "int32"


and more objects here

What you are attempting to do?
What nodes are you using?
What are your inputs?
What output you expect?
Maybe a flow json.
what operating system?
What node is producing the error?
Any code you may be using.
Maybe then someone might pin point what's causing your error.

I am attempting to establish an MQTT communication with Sparkplug B specification

The nodes I am using are inject, function, Sparkplug plus publisher, subscriber and debug (payload) node.

The input is a .json code sent via the function block

msg.payload = {
        "timestamp" : 1504739061501,
        "metrics" : [
                "name" : "Integer001",
                "value" :"1444535466",                               
                "type" : "int32"
                "name" : "String001",
                "value" : "hello",
                "type" : "string"
                "name" : "Boolean001",
                "value" : "true",
                "type" : "boolean"
                "name" : "Float001",
                "value" :"192.192",                               
                "type" : "float"
return msg;

I expect output to be structured objects

OS is Windows 10 Pro

Debug node is producing the error

{Admin edit: wrap code in a ``` codeblock}

it is perfectly valid...

And it is...

If the msg is reaching a debug node, then it is not likely an error in the function - rather something else!

You are going to have to share more info (i.e. export a flow or at minimum a screenshot)

Thank you @Steve-Mcl its working now without any errors. I figured out a fix for it and while the .json format was fine by itself , msg.payload could only be used with as a function block. when I try to use the same .json code in the inject node as a .json input itr gives me error unless I remove the msg.paylaod line and return.msg line.

I am trying to come up with a code or node red flow so that I'd be able to setup SparkplugB based MQTT protocol by making use of the ignition broker.

Yes, that is a very basic node-red knowledge.

In an inject you would enter payload since the entry is already prefixed with msg.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.