# Beginner: String(INT) global variable convert to number?

**URL:** <https://discourse.nodered.org/t/beginner-string-int-global-variable-convert-to-number/81959>\
**Category:** General\
**Tags:** function-node, mqtt\
**Created:** [12 October 2023 08:18 UTC](https://discourse.nodered.org/t/beginner-string-int-global-variable-convert-to-number/81959 "2023-10-12T08:18:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![r4sby](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/r4sby/32/83666_2.png) [@r4sby](https://discourse.nodered.org/u/r4sby)\
**Post date:** [12 October 2023 08:18 UTC](https://discourse.nodered.org/t/beginner-string-int-global-variable-convert-to-number/81959/1 "2023-10-12T08:18:21Z")

</div>

Hi!

First time trying Node-Red with the Weidmuller program.

I have a temperature sensor and I'm trying to get this to convert to $number but I don't understand at all how to go further. Checked forums, youtube etc.

My variable is currently a "Int" (string). I'm new with JavaScript aswell. Have MQTT Explorer connected.  
Any good and easy explanation for a beginner?

 ![fdfd](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c57c16fc1c28797d20ad83d5377f24ebf34016ea.png)  
 ![gragr](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/508d1e04268f8c25fb64a5874a5ef14cec690c9a.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [12 October 2023 10:01 UTC](https://discourse.nodered.org/t/beginner-string-int-global-variable-convert-to-number/81959/3 "2023-10-12T10:01:40Z")

</div>

Hi @r4sby, welcome to the forum.

At the right hand side of ther debug window are a couple of buttons "Copy path" and "Copy value"  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03839c9bb13c3465d281edd164d7af77808587df.png)

If you click Copy path on the line containing your value [and paste it somewhere] you see that the value is at msg.payload.MEASURED\_TEMP.value.

I'm not sure what your change node Jsonata expression is trying to do but it needs to work with the path just shown. This seems to work:

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

You could also convert it using a function node. This would be my approach because I dislike Jsonata syntax.

```auto
msg.payload = Number(msg.payload.MEASURED_TEMP.value);
return msg;

```

---

<div class="post-metadata">

**Author:** ![r4sby](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/r4sby/32/83666_2.png) [@r4sby](https://discourse.nodered.org/u/r4sby)\
**Post date:** [12 October 2023 10:24 UTC](https://discourse.nodered.org/t/beginner-string-int-global-variable-convert-to-number/81959/4 "2023-10-12T10:24:46Z")

</div>

Thank you for a quick reply and good information.

I found out that my variable had 2 outputs, first is "Array of process data",  
Other output "Map of process data". First I used Map of process data, by misstake and figured it out 😀

I also did what you posted. Worked! 😄

---

<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:** [26 October 2023 10:25 UTC](https://discourse.nodered.org/t/beginner-string-int-global-variable-convert-to-number/81959/5 "2023-10-26T10:25:10Z")

</div>

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