# Get value based on object.id

**URL:** <https://discourse.nodered.org/t/get-value-based-on-object-id/66004>\
**Category:** General\
**Tags:** function-node\
**Created:** [4 August 2022 08:47 UTC](https://discourse.nodered.org/t/get-value-based-on-object-id/66004 "2022-08-04T08:47:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Petter](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@Petter](https://discourse.nodered.org/u/Petter)\
**Post date:** [4 August 2022 08:47 UTC](https://discourse.nodered.org/t/get-value-based-on-object-id/66004/1 "2022-08-04T08:47:34Z")

</div>

Hi.  
I have an object with an array of objects. I want to use a function node to get one spesific value based on the object id.  
So if I only want temp from a speseific device/object  
`if msg.payload.object.id == "2920009404" then msg.payload = msg.object.temp`?

 ![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e2da0365ba71a82eafb64ccc5be5081f73b4e189.jpeg)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [4 August 2022 08:59 UTC](https://discourse.nodered.org/t/get-value-based-on-object-id/66004/2 "2022-08-04T08:59:16Z")

</div>

Have a look at the array `filter` function.

---

<div class="post-metadata">

**Author:** ![Petter](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@Petter](https://discourse.nodered.org/u/Petter)\
**Post date:** [5 August 2022 06:20 UTC](https://discourse.nodered.org/t/get-value-based-on-object-id/66004/3 "2022-08-05T06:20:47Z")

</div>

Thanks for the tip. Solved it with this code.

```auto
msg.payload = msg.payload.devices.filter(el => el.id === "V004b11e12")
msg.payload = msg.payload[0].data.controlSignal

return msg;

```

---

<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:** [19 August 2022 06:20 UTC](https://discourse.nodered.org/t/get-value-based-on-object-id/66004/4 "2022-08-19T06:20:53Z")

</div>

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