# STRING node - stuck SOLVED! Sorry!

**URL:** <https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110>\
**Category:** General\
**Created:** [27 June 2018 03:27 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110 "2018-06-27T03:27:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [27 June 2018 03:27 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/1 "2018-06-27T03:27:12Z")

</div>

Sorry folks. Seems the elephant is back in the room.

This is the bare bones of what I am wanting to do:

```auto
[{"id":"77182547.31a85c","type":"string","z":"d52027c9.60c9f8","name":"","methods":[{"name":"chompLeft","params":[{"type":"str","value":"COMMAND_REPLY"}]}],"prop":"topic","propout":"payload","object":"msg","objectout":"msg","x":430,"y":140,"wires":[["b4edeabd.882af"]]},{"id":"b4edeabd.882af","type":"debug","z":"d52027c9.60c9f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","x":600,"y":140,"wires":[]},{"id":"ec25ae89.d3cb7","type":"inject","z":"d52027c9.60c9f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":140,"wires":[["957dca8c.5f4d88"]]},{"id":"957dca8c.5f4d88","type":"function","z":"d52027c9.60c9f8","name":"","func":"msg.topic = \"COMMAND_REPLY/TimePi\";\nmsg.payload = \"Test message\"\nreturn msg;","outputs":1,"noerr":0,"x":220,"y":140,"wires":[["77182547.31a85c"]]}]

```

Idea:  
The topic is “COMMAND\_REPLY/(device name)”  
and I want to strip that to “device name”.

I use the STRING node and CHOMPLEFT COMMAND\_REPLY/ of the topic.

But it doesn’t seem to be working.

Where’s the elephant?

AH!

STRING node returns its results in PAYLOAD irrespective of from where the input was sourced!  
I was playing with (msg.)topic and expected the result to REMAIN in topic.

Seems it is put in payload.

Nice if that was declared a bit clearer. Is it?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2018 06:25 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/2 "2018-06-27T06:25:28Z")

</div>

I think you’ve just mis-read it.

You can change the output to be delivered in msg.topic instead of msg.payload

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [27 June 2018 06:41 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/3 "2018-06-27T06:41:40Z")

</div>

Yup. Classic foot in mouth for me.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2018 08:30 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/4 "2018-06-27T08:30:43Z")

</div>

JFI the node-red-contrib-string node doesn’t actually work on my Win10 setup so it may not be a reliable node to use

I’d recommend rolling your own function node or using a change node with a bit of JSONata instead

[edit]Duff gen see later post[/edit]

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 June 2018 09:45 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/5 "2018-06-27T09:45:13Z")

</div>

> [@cymplecy](#):
>
> node-red-contrib-string node doesn’t actually work on my Win10 setu

Can you provide a minimal flow showing the problem please? I would have expected it to work ok.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [27 June 2018 13:49 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/6 "2018-06-27T13:49:05Z")

</div>

I would use a `change` node to do this… Set `msg.` `topic` to the `J:` expression  
`topic.$substringAfter("/")`

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2018 20:18 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/8 "2018-06-27T20:18:23Z")

</div>

oops - my error - didn’t realise that OP had changed debug node to show topic - it is working for me 🙂

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [27 June 2018 22:12 UTC](https://discourse.nodered.org/t/string-node-stuck-solved-sorry/1110/9 "2018-06-27T22:12:58Z")

</div>

Thanks Steve.

I got fooled by not looking at the bottom of the window where it sets the output part.

So as much as I set it to parse the msg.TOPIC, I didn’t set it to return the result in msg.topic.

Worked around the problem in the mean time.

All good.

Thanks.
