Naming msg.payload after join node

Hello. Is there anything I can do to change the object name after passing the join node? I notice sometimes the output will changing and this might became a problem If i were to add some function dedicated to that object. Any help would be appreciated! Thanks!

[
    {
        "id": "9c5a65d43c1c7876",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "6b910709349bc7f2",
        "type": "inject",
        "z": "9c5a65d43c1c7876",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "topic1",
        "payload": "1",
        "payloadType": "str",
        "x": 130,
        "y": 40,
        "wires": [
            [
                "d70c23422362c6b6"
            ]
        ]
    },
    {
        "id": "a2a2c0a31faf29c0",
        "type": "inject",
        "z": "9c5a65d43c1c7876",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "topic2",
        "payload": "2",
        "payloadType": "str",
        "x": 130,
        "y": 120,
        "wires": [
            [
                "d70c23422362c6b6"
            ]
        ]
    },
    {
        "id": "d70c23422362c6b6",
        "type": "join",
        "z": "9c5a65d43c1c7876",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": true,
        "timeout": "",
        "count": "2",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 310,
        "y": 80,
        "wires": [
            [
                "a80e79598b25f83b"
            ]
        ]
    },
    {
        "id": "a80e79598b25f83b",
        "type": "join",
        "z": "9c5a65d43c1c7876",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "2",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 490,
        "y": 140,
        "wires": [
            [
                "eb0577b6dd1671f7"
            ]
        ]
    },
    {
        "id": "aa17049f4ddb1257",
        "type": "inject",
        "z": "9c5a65d43c1c7876",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "topic3",
        "payload": "3",
        "payloadType": "str",
        "x": 270,
        "y": 200,
        "wires": [
            [
                "a80e79598b25f83b"
            ]
        ]
    },
    {
        "id": "eb0577b6dd1671f7",
        "type": "debug",
        "z": "9c5a65d43c1c7876",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 710,
        "y": 120,
        "wires": []
    }
]

After the first join node set the msg.topic to what you want, as it will change depending on the order topic1 & 2 arrive.
e.g.

[{"id":"6b910709349bc7f2","type":"inject","z":"9c5a65d43c1c7876","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic1","payload":"1","payloadType":"str","x":130,"y":40,"wires":[["d70c23422362c6b6"]]},{"id":"d70c23422362c6b6","type":"join","z":"9c5a65d43c1c7876","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":310,"y":80,"wires":[["eb0577b6dd1671f7","4f3828b8.e66108"]]},{"id":"a2a2c0a31faf29c0","type":"inject","z":"9c5a65d43c1c7876","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic2","payload":"2","payloadType":"str","x":130,"y":120,"wires":[["d70c23422362c6b6"]]},{"id":"eb0577b6dd1671f7","type":"debug","z":"9c5a65d43c1c7876","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":120,"wires":[]},{"id":"4f3828b8.e66108","type":"change","z":"9c5a65d43c1c7876","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":120,"wires":[["a80e79598b25f83b"]]},{"id":"a80e79598b25f83b","type":"join","z":"9c5a65d43c1c7876","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":160,"wires":[["eb0577b6dd1671f7"]]},{"id":"aa17049f4ddb1257","type":"inject","z":"9c5a65d43c1c7876","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic3","payload":"3","payloadType":"str","x":270,"y":200,"wires":[["a80e79598b25f83b"]]}]
1 Like

Anddd..done! Thank you very much. It is so simple and yet I can't figured it out lol

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