# Is it possible to pass query SQL result to a notification node?

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990>\
**Category:** General\
**Created:** [17 March 2022 14:41 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990 "2022-03-17T14:41:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [17 March 2022 14:41 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/1 "2022-03-17T14:41:26Z")

</div>

Hello,

I would like to send the result of a query to a database sql table to a notification node (like a pop-up in which is reported the list output of the query, which an array).

By a botton I want to send the query to my SQL table, get an array as result and send it to a pop-up.  
Is there this possibility?

Thanks

---

<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:** [17 March 2022 15:59 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/2 "2022-03-17T15:59:31Z")

</div>

Of course.

You need to create a user interface though. Most easily done using the Dashboard nodes. Remember that Dashboard runs in a client browser and Node-RED on a server. So you need a UI with a button, when pressed, that triggers a flow in Node-RED that formulates and executes the query and then returns the data back to the UI. Dashboard will let you create a UI with minimal coding. But you can also use a http-in/-out pair with some processing, uibuilder, or one of the other ui nodes.

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [24 March 2022 13:46 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/3 "2022-03-24T13:46:01Z")

</div>

Could you be more specific linking to an example?

I have created the flow like this:

 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef16250eaa1d40fe5b13e5f4ddb78e14ba2e8b78.png)

the ouptut of change node is:  
 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e098b5fb1029d5c0bda37b35f026bbc60d79123.png)

The point is (I think) that I have an array whose size can change each time a make a request to the SQL table), so I don't know how to pass it.

Thanks

---

<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:** [24 March 2022 14:16 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/4 "2022-03-24T14:16:02Z")

</div>

Don't know about an example. But it looks like you need to learn how to make use of the template node to create a repeating output based on the msg.payload. The template node, as it says in the help, uses Mustache to do this. So you need to know how to use Mustache.

---

<div class="post-metadata">

**Author:** ![Nathanli](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@Nathanli](https://discourse.nodered.org/u/Nathanli)\
**Post date:** [31 March 2022 14:20 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/5 "2022-03-31T14:20:58Z")

</div>

Sure, but you need to create a user interface first

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [31 March 2022 14:43 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/6 "2022-03-31T14:43:18Z")

</div>

I created the UI, what I want is that when button is clicked, a pop-up is opened showing the output which comes from a query to sql table. The point is how to pass the result of my query to the notification node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 March 2022 15:24 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/7 "2022-03-31T15:24:07Z")

</div>

Put whatever string you want as the title in msg.topic and the string you want to appear as the text in msg.payload. Send the message to a ui\_notification node.

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [1 April 2022 12:24 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/8 "2022-04-01T12:24:32Z")

</div>

Thanks Colin.

Do you mean by using the button node?

```auto
[{"id":"d332c5f44a92d664","type":"ui_button","z":"e0129591b64c21bc","name":"","group":"c9af264e236d9442","order":18,"width":3,"height":1,"passthru":false,"label":"Visualizza Famiglie Esistenti","tooltip":"","color":"","bgcolor":"#A6BBCF","className":"","icon":"","payload":"payload[1]","payloadType":"flow","topic":"Le famiglie esistenti sono:","topicType":"str","x":180,"y":1260,"wires":[["95081c31aea3614e","d7ef55c75ada7677"]]},{"id":"95081c31aea3614e","type":"MSSQL","z":"e0129591b64c21bc","mssqlCN":"6fb70e68d89e36c4","name":"","outField":"payload","returnType":"0","throwErrors":"0","query":"SELECT FAMIGLIA FROM [DB_Strumentazione].[dbo].[StrumentazioneAttrezzature]\nGROUP BY FAMIGLIA","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"queryParams","paramsOptType":"msg","rows":"","rowsType":"msg","params":[{"output":true,"name":"CODIFICA","type":"VarChar","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":420,"y":1260,"wires":[["fe5175807e83799e","36f3c336c290ba0a"]]},{"id":"fe5175807e83799e","type":"ui_toast","z":"e0129591b64c21bc","position":"dialog","displayTime":"7","highlight":"red","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":650,"y":1260,"wires":[["46e7ca8675a3e147"]]},{"id":"36f3c336c290ba0a","type":"debug","z":"e0129591b64c21bc","name":"out DB","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":1200,"wires":[]},{"id":"d7ef55c75ada7677","type":"debug","z":"e0129591b64c21bc","name":"button","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":270,"y":1200,"wires":[]},{"id":"46e7ca8675a3e147","type":"debug","z":"e0129591b64c21bc","name":"notif","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":1320,"wires":[]},{"id":"c9af264e236d9442","type":"ui_group","name":"Group 1","tab":"c4b6a8a406b3fbe5","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"6fb70e68d89e36c4","type":"MSSQL-CN","name":"DB_Strumentazione","server":"GIOVANNAQ\\SQLEXPRESS","port":"","encyption":true,"trustServerCertificate":true,"database":"DB_Strumentazione","useUTC":false,"connectTimeout":"","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false,"enableArithAbort":true},{"id":"c4b6a8a406b3fbe5","type":"ui_tab","name":"Inserimento Strumento-Attrezzatura","icon":"dashboard","order":3,"disabled":false,"hidden":true}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 April 2022 12:55 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/9 "2022-04-01T12:55:39Z")

</div>

> [@QGIO](#):
>
> Do you mean by using the button node?

Well you said that is what you want to do, so I assumed you knew how to do that bit.

The notification node expects a string, so you will have to put whatever you want to display there in string format. What _exactly_ do you want to appear in the notification? If you are trying to display a table of data then perhaps you would be better using ui-table, but then it would not be a popup. You could hide it and show as required though, I think.

---

<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:** [31 May 2022 12:56 UTC](https://discourse.nodered.org/t/is-it-possible-to-pass-query-sql-result-to-a-notification-node/59990/10 "2022-05-31T12:56:12Z")

</div>

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