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

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

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.

Could you be more specific linking to an example?

I have created the flow like this:

the ouptut of change node is:
immagine

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

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.

Sure, but you need to create a user interface first

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.

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.

Thanks Colin.

Do you mean by using the button node?

[{"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}]

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.