Replace a JSON value with string of a TAIL node

Hi Community,
I´m a fresh man in NR and need your help.
I try to use a string from my TAIL node and use this string to replace a placeholder in my JSON Object which I will use as a http POST request.
I stuck with the replacing. I have no idea how to replace the JSON value ("#????") with my value from my "tail-string" (e.g. DC12)

Thx !!

[{"id":"44f39358.4f8b4c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b0be09cb.e33aa8","type":"http request","z":"44f39358.4f8b4c","name":"Agilox Workflow","method":"POST","ret":"obj","paytoqs":"ignore","url":"http://141.73.250.4:8100/workflow/0","tls":"","persist":false,"proxy":"","authType":"","x":560,"y":300,"wires":[["9c9bd940.eb1fa8","59e8e1ec.845ec"]]},{"id":"9c9bd940.eb1fa8","type":"debug","z":"44f39358.4f8b4c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":260,"wires":[]},{"id":"59e8e1ec.845ec","type":"file","z":"44f39358.4f8b4c","name":"Agilox Order Logfile","filename":"C:\\Users\\xxxx\\Desktop\\Agilox.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":830,"y":320,"wires":[[]]},{"id":"da10ec19.d874a","type":"tail","z":"44f39358.4f8b4c","name":"agilox","filetype":"text","split":"[\\r]{0,1}\\n","filename":"C:\\\\Users\\\\xxx\\\\Desktop\\\\Node-Red Test\\\\Agilox.txt","inputs":0,"x":90,"y":400,"wires":[["648d22c8.cccd7c","cf308e72.2fb21"]]},{"id":"648d22c8.cccd7c","type":"debug","z":"44f39358.4f8b4c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":400,"wires":[]},{"id":"cf308e72.2fb21","type":"change","z":"44f39358.4f8b4c","name":"Destination zufügen","rules":[{"t":"set","p":"payload","pt":"msg","to":"{    \"SOURCE\": **#??????**?,    \"DESTINATION\": \"DC16\",    \"PRIORITY\": 50,    \"userdata\": {        \"host_orderid\": 3541387    }}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":300,"wires":[["b0be09cb.e33aa8"]]}]

Hi, in order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json

sry, thank you for the hint

It is really difficult to understand what you are trying to achieve.

If you have a JS object, just use a change node to set msg.payload.SOURCE to whatever value you want.

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

You can also use JSONata in the change node as below

[{"id":"1549ec9d.6caf3b","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"75b850c4.fc461","type":"http request","z":"1549ec9d.6caf3b","name":"Agilox Workflow","method":"POST","ret":"obj","paytoqs":"ignore","url":"http://141.73.250.4:8100/workflow/0","tls":"","persist":false,"proxy":"","authType":"","x":560,"y":300,"wires":[["105dc6b1.05c161","f6f83eb6.6d26"]]},{"id":"105dc6b1.05c161","type":"debug","z":"1549ec9d.6caf3b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":260,"wires":[]},{"id":"f6f83eb6.6d26","type":"file","z":"1549ec9d.6caf3b","name":"Agilox Order Logfile","filename":"C:\\Users\\xxxx\\Desktop\\Agilox.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":830,"y":320,"wires":[[]]},{"id":"7e67540c.e4db34","type":"tail","z":"1549ec9d.6caf3b","name":"agilox","filetype":"text","split":"[\\r]{0,1}\\n","filename":"C:\\\\Users\\\\xxx\\\\Desktop\\\\Node-Red Test\\\\Agilox.txt","inputs":0,"x":90,"y":400,"wires":[["2c3f3bb7.4322e4","b2f57bb2.f0c31"]]},{"id":"2c3f3bb7.4322e4","type":"debug","z":"1549ec9d.6caf3b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":400,"wires":[]},{"id":"b2f57bb2.f0c31","type":"change","z":"1549ec9d.6caf3b","name":"Destination zufügen","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t   \"SOURCE\": payload,\t   \"DESTINATION\":\"DC16\",\t   \"PRIORITY\":50,\t   \"userdata\":{\"host_orderid\":3541387}\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":300,"wires":[["75b850c4.fc461"]]}]
1 Like

Thanks Steve-Mci & E1cid !!
@E1cid: your solution works perfect !!
@Steve-Mcl: thanks for your patience and your hints!

Now I´ve unterstood the method of msg.payload !

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