# How to split flow after x payload characters?

**URL:** <https://discourse.nodered.org/t/how-to-split-flow-after-x-payload-characters/80830>\
**Category:** General\
**Created:** [26 August 2023 22:16 UTC](https://discourse.nodered.org/t/how-to-split-flow-after-x-payload-characters/80830 "2023-08-26T22:16:08Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 August 2023 17:02 UTC](https://discourse.nodered.org/t/how-to-split-flow-after-x-payload-characters/80830/21 "2023-08-30T17:02:29Z")

</div>

How would I know without the incoming data you used.

p.s. Did you use the new edited change nodes? I posted an edit in post above.

[edit] Moved the chnage node expressions into the function node code.

```auto
[{"id":"e09171211ffbfead","type":"inject","z":"b9860b4b9de8c8da","name":"topic","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"G\":\"cmnd/tasmota_02B2D1\"},{\"G\":\"cmnd/tasmota_02A70A\"},{\"G\":\"cmnd/tasmota_228C3D\"}]","payloadType":"json","x":50,"y":100,"wires":[["43fe307ae4cf1f61"]]},{"id":"43fe307ae4cf1f61","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"topic","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":100,"wires":[["fbf95049ca9763a2"]]},{"id":"fbf95049ca9763a2","type":"join","z":"b9860b4b9de8c8da","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":230,"y":160,"wires":[["c72488515dd06cac"]]},{"id":"1ea45af6d6227871","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"rule","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":220,"wires":[["fbf95049ca9763a2"]]},{"id":"c72488515dd06cac","type":"function","z":"b9860b4b9de8c8da","name":"function 21","func":"const payload = RED.util.cloneMessage(msg.payload);\n//payload.rule = Object.values(payload.rule);\n//payload.topic = Object.values(payload.topic);\n//node.warn(payload)\npayload.rule.forEach((obj, index) => {\n let input = Object.values(obj)[0].split(/\\s/);\n msg.topic = Object.values(payload.topic[index])[0] + \"/Rule1\";\n let output = \"\";\n let space = \"\";\n input.forEach(str => {\n if(output.length + str.length >= 500){\n msg.payload = output;\n node.send(msg);\n output = \"+\" + str + \" \";\n space = \"\";\n }else{\n output = output + space + str;\n space = \" \";\n }\n });\n if (output.length > 0){\n msg.payload = output;\n node.send(msg);\n }\n})\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":200,"wires":[["718a49e7e3eb66de"]]},{"id":"0ef39fc347e7ebdb","type":"inject","z":"b9860b4b9de8c8da","name":"rule1","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"V\":\"blah blah1\"}]","payloadType":"json","x":50,"y":220,"wires":[["1ea45af6d6227871"]]},{"id":"718a49e7e3eb66de","type":"delay","z":"b9860b4b9de8c8da","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"4","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":530,"y":160,"wires":[["108b05d9ff8e3457"]]},{"id":"108b05d9ff8e3457","type":"debug","z":"b9860b4b9de8c8da","name":"debug 330","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":100,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![AleXSR700](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexsr700/32/41161_2.png) [@AleXSR700](https://discourse.nodered.org/u/AleXSR700)\
**Post date:** [30 August 2023 17:06 UTC](https://discourse.nodered.org/t/how-to-split-flow-after-x-payload-characters/80830/22 "2023-08-30T17:06:18Z")

</div>

Did not see the change and then overlooked the change to the change node of the topic. -.-

It seems to be working now. I will do an extensive test and report back 🙂

You make it look so simple 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 September 2023 17:06 UTC](https://discourse.nodered.org/t/how-to-split-flow-after-x-payload-characters/80830/23 "2023-09-13T17:06:34Z")

</div>

Closed on 13 September 2023 17:06 UTC

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

[Previous page](https://discourse.nodered.org/t/how-to-split-flow-after-x-payload-characters/80830.md?page=1)
