# Object to specific string

**URL:** <https://discourse.nodered.org/t/object-to-specific-string/12789>\
**Category:** General\
**Created:** [1 July 2019 17:50 UTC](https://discourse.nodered.org/t/object-to-specific-string/12789 "2019-07-01T17:50:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![node-n00b](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@node-n00b](https://discourse.nodered.org/u/node-n00b)\
**Post date:** [1 July 2019 17:50 UTC](https://discourse.nodered.org/t/object-to-specific-string/12789/1 "2019-07-01T17:50:28Z")

</div>

Dear Community, i am using Node Red since 3 Months now and did a good learning on it.  
But i am stuck all day long, and not quite good @ js.  
I Have a SMS Gateway Which accepts a payload of: NUMBER\_TEXT\_. e.g: +46887656\_Test SMS \_  
The underscores are for the gateway to know waht is sms and text.  
I have problems to do concatenation...

I want to use a form (dashboard) to send sms.

Form gives following object:

msg.payload : Object  
object  
Number: "1234"  
Text: "test"

I tried following via function:

var txt=msg.payload.Text  
var nmbr=msg.payload.Number

var msg1 =  
{  
payload:nmbr  
};  
var msg2 =  
{  
payload:txt  
};

msg.payload = "";  
msg.payload += msg1;  
msg.payload += "_";  
msg.payload += msg2;  
msg.payload += "_";  
return msg.payload;

Can anyone help me to concat taht string??? I am Totally stuck ...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 July 2019 18:07 UTC](https://discourse.nodered.org/t/object-to-specific-string/12789/2 "2019-07-01T18:07:58Z")

</div>

Well you could use a function and do

```
msg.payload = msg.payload.Number + "_" + msg.payload.Text + "_";
return msg;

```

To concatenate the two parts - inserting the underscores that you seem to need also.

---

<div class="post-metadata">

**Author:** ![node-n00b](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@node-n00b](https://discourse.nodered.org/u/node-n00b)\
**Post date:** [3 July 2019 17:13 UTC](https://discourse.nodered.org/t/object-to-specific-string/12789/3 "2019-07-03T17:13:44Z")

</div>

hy, thankks tht worked!!  
Sorry, still on learing the basics...

regards node-n00b

---

<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:** [12 July 2019 03:45 UTC](https://discourse.nodered.org/t/object-to-specific-string/12789/4 "2019-07-12T03:45:11Z")

</div>

A slightly less "programming-language" way to do this would be a simple `template` node --

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/309cbc509a6a7c0bb02540bd16125053640c0875.png)

it uses _mustache_ syntax to do variable replacement within the surrounding text, so your use case could be written as `{{payload.Number}}_{{payload.Text}}_`

_Note that the leading_ `msg.` _needs to be left off of your variable names, since the entire `msg` object is already used as the source of those variables_
