# Msg from function block

**URL:** <https://discourse.nodered.org/t/msg-from-function-block/61207>\
**Category:** General\
**Tags:** function-node\
**Created:** [12 April 2022 22:51 UTC](https://discourse.nodered.org/t/msg-from-function-block/61207 "2022-04-12T22:51:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [15 April 2022 13:47 UTC](https://discourse.nodered.org/t/msg-from-function-block/61207/3 "2022-04-15T13:47:44Z")

</div>

If you had used the code I gave you in your other post, you would see I pushed the oid into the topic.

> [@Function output payload](https://discourse.nodered.org/t/function-output-payload/61098/2):
>
> Firstly, is there a reason you are not using [node-red-node-snmp](https://flows.nodered.org/node/node-red-node-snmp)? Secondly, as you are running async code, you cannot return msg you need to use [node.send](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously) e.g.... // NPM module exposed as variable, npm\_module const session = snmp.createSession ("192.168.10.250", "public"); const oids = ["1.3.6.1.2.1.1.1.0"]; session.get (oids, function (error, varbinds) { if (error) { node.error(error, msg); } else { for (let i = 0; i \< varbinds.length; i++) { const e = sn…

Then after the function, you can simply use a switch node to route the message based on `msg.topic`

---

_[View the full topic](https://discourse.nodered.org/t/msg-from-function-block/61207)._
