# Use input msg.payload after postgres node

**URL:** <https://discourse.nodered.org/t/use-input-msg-payload-after-postgres-node/85994>\
**Category:** General\
**Created:** [28 February 2024 11:05 UTC](https://discourse.nodered.org/t/use-input-msg-payload-after-postgres-node/85994 "2024-02-28T11:05:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prodoreda](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@prodoreda](https://discourse.nodered.org/u/prodoreda)\
**Post date:** [28 February 2024 11:05 UTC](https://discourse.nodered.org/t/use-input-msg-payload-after-postgres-node/85994/1 "2024-02-28T11:05:42Z")

</div>

I'm trying to manage an alarm system using Node-RED.

Giving a function node that sends out multiple messages using **node.send()** method or giving a split node, I need to check if each value exists in a PostgreSQL database (SELECT statement), so after the postgres node I wish to get the input msg.payload in order to perform some actions using the payload values.

`[function node] -> [postgres node] -> [switch node] -> [...]`

How can I get the **msg.payload** generated in the output of the _funciton node_ in the switch node?

I tried using a _change node_ after the _function node_ setting the payload as flow var, but it does not work. In the _switch node_ I always see the last message sent out from the _function node_.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 February 2024 11:09 UTC](https://discourse.nodered.org/t/use-input-msg-payload-after-postgres-node/85994/2 "2024-02-28T11:09:03Z")

</div>

Copy the payload to a different property in the msg (e.g. msg.payloadOrig) using a change node, just before the Pg node then after, you can move it back (or just use msg.payloadOrig in the switch property instead)

---

<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:** [13 March 2024 11:09 UTC](https://discourse.nodered.org/t/use-input-msg-payload-after-postgres-node/85994/3 "2024-03-13T11:09:40Z")

</div>

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