# Integer from a payload with the function node

**URL:** <https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671>\
**Category:** General\
**Created:** [24 February 2023 08:21 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671 "2023-02-24T08:21:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [24 February 2023 08:21 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/1 "2023-02-24T08:21:37Z")

</div>

NR receives a payload from a Seeed node that contains the light intensity in lux (image). The path of the decoded luminosity payload is:

_payload.uplink\_message.decoded\_payload.messages[0].measurementValue_

With a function node I only want to use an integer with the de lux value (as in example 4099) and I can't do that. The code below generates an error and as a beginner I wouldn't know how else to do it. Can someone help me with this?

```auto
var newMsg = { payload: payload.uplink_message.decoded_payload.messages[0].measurementValue };
return newMsg

```

![NR](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/2030f3f970959989db35163541fd82e9fb121c11.png)

---

<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:** [24 February 2023 08:27 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/2 "2023-02-24T08:27:45Z")

</div>

Just to the right of that `4099` value if you move the mouse there, a couple of icons appear.

One will look like `>_`  
That copies the PATH.

Click on it then paste the value here.

Poor example of where this is.

![Screenshot from 2023-02-24 19-26-17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9cd1884e943f5ee5ecf18ac8a890ba99ac72fc89.png)

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [24 February 2023 08:29 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/3 "2023-02-24T08:29:32Z")

</div>

> [@HaVi](#):
>
> payload.uplink\_message.decoded\_payload.messages[0].measurementValue

Thanks for helping. The path is:

```auto
payload.uplink_message.decoded_payload.messages[0].measurementValue

```

---

<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:** [24 February 2023 08:31 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/4 "2023-02-24T08:31:13Z")

</div>

In the `function` node:

```auto
let x = msg.payload.uplink_message.decoded_payload.messages[0].measurementValue;
msg.payload = x;
return msg;

```

I think that should work.

**IF** you don't want anything else from the message.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [24 February 2023 08:49 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/5 "2023-02-24T08:49:26Z")

</div>

You solved my problem, thank you very much!

---

<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:** [24 February 2023 08:49 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/6 "2023-02-24T08:49:50Z")

</div>

Glad I could help.

---

<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:** [10 March 2023 08:50 UTC](https://discourse.nodered.org/t/integer-from-a-payload-with-the-function-node/75671/7 "2023-03-10T08:50:11Z")

</div>

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