I'm moving to this approach, but I'm not getting the download (when I click the button it seems that it finds and finds for long time)
[{"id":"98261154.3006","type":"http response","z":"84f44064.d1cf4","name":"","statusCode":"","headers":{},"x":1930,"y":1900,"wires":[]},{"id":"34dc99e5.495466","type":"file in","z":"84f44064.d1cf4","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1770,"y":1840,"wires":[["98261154.3006","1d293b0ca54c1c08"]]},{"id":"38d65d59.1d8aa2","type":"catch","z":"84f44064.d1cf4","name":"","scope":null,"uncaught":false,"x":1400,"y":1940,"wires":[["3b8014a.86ad8ec","5b18a8e7.fb8da8"]]},{"id":"3b8014a.86ad8ec","type":"function","z":"84f44064.d1cf4","name":"Set 404","func":"msg.payload = msg.error;\nmsg.statusCode = 404;//resource not found\nreturn msg;","outputs":1,"noerr":0,"x":1780,"y":1940,"wires":[["98261154.3006"]]},{"id":"5b18a8e7.fb8da8","type":"debug","z":"84f44064.d1cf4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1430,"y":1980,"wires":[]},{"id":"a8c2985e.d23ad8","type":"ui_template","z":"84f44064.d1cf4","d":true,"group":"dfb4a60f.d788f8","name":"ui_temlplate - present download links on dashboard","order":0,"width":0,"height":0,"format":"<div >\n <a href=\"/files/Scadenziario.pdf\">download </a>\n \n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":1770,"y":2020,"wires":[[]]},{"id":"67ecfa7f.3f0e24","type":"http in","z":"84f44064.d1cf4","name":"","url":"/download","method":"get","upload":false,"swaggerDoc":"","x":1500,"y":1860,"wires":[["52efc42f369d2e50"]]},{"id":"1d293b0ca54c1c08","type":"debug","z":"84f44064.d1cf4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1990,"y":1820,"wires":[]},{"id":"f5b7f2fa75d470cc","type":"ui_dropdown","z":"84f44064.d1cf4","name":"","label":"Cerca Strumento","tooltip":"","place":"","group":"c33a1024a72aa169","order":2,"width":4,"height":1,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"options","topicType":"msg","className":"","x":870,"y":1500,"wires":[["93c701732606cfa1","55409b5ed218ba79","677fc548f7da5acd"]]},{"id":"b7db2284cba0b89b","type":"MSSQL","z":"84f44064.d1cf4","mssqlCN":"6fb70e68d89e36c4","name":"","outField":"payload","returnType":"0","throwErrors":"0","query":"SELECT CODIFICA FROM [DB_Strumentazione].[dbo].[StrumentazioneAttrezzature]","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":400,"y":1360,"wires":[["431815359165648b","8c7dbc9e8e230e43"]]},{"id":"431815359165648b","type":"debug","z":"84f44064.d1cf4","name":"Out DB","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":1380,"wires":[]},{"id":"8804f7556a111162","type":"inject","z":"84f44064.d1cf4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"Inserimento Date Controllo","payloadType":"date","x":250,"y":1420,"wires":[["b7db2284cba0b89b"]]},{"id":"cbb8236c9040a05d","type":"ui_button","z":"84f44064.d1cf4","name":"","group":"c33a1024a72aa169","order":1,"width":6,"height":1,"passthru":false,"label":"Refresh Data","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":290,"y":1260,"wires":[["b7db2284cba0b89b","cb370eaf5b56855d"]]},{"id":"8c7dbc9e8e230e43","type":"change","z":"84f44064.d1cf4","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"$.payload.CODIFICA","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1440,"wires":[["f5b7f2fa75d470cc"]]},{"id":"44a8e3026bebc795","type":"link in","z":"84f44064.d1cf4","name":"Cerca IN","links":["903c900237df9b06","a4e99335d55b5a73"],"x":635,"y":1500,"wires":[["f5b7f2fa75d470cc"]]},{"id":"cb370eaf5b56855d","type":"link out","z":"84f44064.d1cf4","name":"Refresh OUT","mode":"link","links":["e2f623abc2306f64","9e3baa52c3d5110c"],"x":475,"y":1260,"wires":[]},{"id":"93c701732606cfa1","type":"MSSQL","z":"84f44064.d1cf4","mssqlCN":"6fb70e68d89e36c4","name":"","outField":"payload","returnType":"0","throwErrors":"0","query":"SELECT [dbo].[SCADENZIARIO].ID as ID_Scad, [dbo].[StrumentazioneAttrezzature].CODIFICA\nFROM [dbo].[SCADENZIARIO]\nINNER JOIN [dbo].[StrumentazioneAttrezzature]\nON [dbo].[SCADENZIARIO].ID_STRUM = [dbo].[StrumentazioneAttrezzature].ID\nWHERE [dbo].[StrumentazioneAttrezzature].CODIFICA = (@CODIFICA) ","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"","rowsType":"msg","params":[{"output":false,"name":"CODIFICA","type":"VarChar","valueType":"msg","value":"payload","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":1020,"y":1300,"wires":[["20f0b79d7e14e5e3","eff66b976af5f804"]]},{"id":"12f4fcbd49942947","type":"change","z":"84f44064.d1cf4","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload.ID_Scad[]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":1360,"wires":[["aa07b76f54e154c5","f22ac411b2fc1c11"]]},{"id":"20f0b79d7e14e5e3","type":"debug","z":"84f44064.d1cf4","name":"After Request SQL","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1280,"y":1420,"wires":[]},{"id":"eff66b976af5f804","type":"switch","z":"84f44064.d1cf4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1190,"y":1300,"wires":[["7a6cf6ae970e18bd"],["12f4fcbd49942947"]]},{"id":"7a6cf6ae970e18bd","type":"change","z":"84f44064.d1cf4","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":1300,"wires":[["f22ac411b2fc1c11"]]},{"id":"aa07b76f54e154c5","type":"debug","z":"84f44064.d1cf4","name":"Change Node","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1520,"y":1440,"wires":[]},{"id":"f22ac411b2fc1c11","type":"function","z":"84f44064.d1cf4","name":"","func":"op = [];\nfor(var i = 0; i < msg.options.length; i++) {\n op.push(msg.options[i] + \"\")\n}\nmsg = {};\n\nmsg.options = op;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1560,"y":1360,"wires":[["3004974ca3339fcb"]]},{"id":"3004974ca3339fcb","type":"ui_dropdown","z":"84f44064.d1cf4","name":"","label":"Which ID?","tooltip":"","place":"Select option","group":"c33a1024a72aa169","order":3,"width":6,"height":1,"passthru":false,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"IDAll","topicType":"str","className":"","x":1790,"y":1340,"wires":[["d02cdceb1c18f1fc"]]},{"id":"7b206d637cc3e465","type":"change","z":"84f44064.d1cf4","name":"","rules":[{"t":"set","p":"payload.file","pt":"msg","to":"filename_counter","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1960,"y":1640,"wires":[[]]},{"id":"55409b5ed218ba79","type":"change","z":"84f44064.d1cf4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"fileCOD","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1410,"y":1540,"wires":[["d02cdceb1c18f1fc"]]},{"id":"51cab21518b322e3","type":"debug","z":"84f44064.d1cf4","name":"Cod_ID","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1800,"y":1480,"wires":[]},{"id":"d02cdceb1c18f1fc","type":"join","z":"84f44064.d1cf4","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1630,"y":1540,"wires":[["51cab21518b322e3","52efc42f369d2e50"]]},{"id":"52efc42f369d2e50","type":"function","z":"84f44064.d1cf4","name":"","func":"var path = \"C:\\\\Datamed\\\\DB_Strumentazione\\\\Node-red\\\\\";\nvar filename = msg.payload.fileCOD + \"_\" + msg.payload.IDAll;\nvar ext = \".pdf\"\n//msg.payload.file = path + filename + ext\nmsg.filename=path + filename + ext\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1700,"y":1640,"wires":[["02ef66922022d5ec","7b206d637cc3e465","ebf23d0a6cf1eceb","34dc99e5.495466"]]},{"id":"02ef66922022d5ec","type":"debug","z":"84f44064.d1cf4","name":"func out","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1970,"y":1540,"wires":[]},{"id":"ebf23d0a6cf1eceb","type":"ui_template","z":"84f44064.d1cf4","d":true,"group":"c33a1024a72aa169","name":"","order":6,"width":"4","height":"9","format":"\n<br/>\n<table id=\"table\" border=\"1\" height= 50px >\n\n <tr>\n <th>ID_ALLEG</th>\n <th>ALLEGATO</th> \n \n </tr>\n <tbody style=\"text-align: center\">\n <tr ng-repeat=\"x in msg.payload\">\n \n <td> {{x.ID_Scad}} </td>\n <td ng-if=\"x.STATOALLEGATO == 0\"> Not Available </td>\n <td ng-if=\"x.STATOALLEGATO == 1\"><a href=\"/download/{{x.file}}\">Download</a>\n </tr>\n </tbody>\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":1860,"y":1760,"wires":[[]]},{"id":"677fc548f7da5acd","type":"MSSQL","z":"84f44064.d1cf4","mssqlCN":"6fb70e68d89e36c4","name":"","outField":"payload","returnType":"0","throwErrors":"0","query":"SELECT [dbo].[SCADENZIARIO].ID as ID_Scad,\n[dbo].[SCADENZIARIO].ID_STRUM,\nFORMAT( DATAULTIMOCONTROLLO, 'yyyy-MM-dd') as DATAULTIMOCONTROLLO,\n[dbo].[SCADENZIARIO].RESPONSABILE,\n[dbo].[SCADENZIARIO].STATO, \n[dbo].[StrumentazioneAttrezzature].ID,\n[dbo].[SCADENZIARIO].ALLEGATO, \n(case when [dbo].[SCADENZIARIO].ALLEGATO is not null then 1\n when [dbo].[SCADENZIARIO].ALLEGATO is null then 0\n end) as STATOALLEGATO,\n[dbo].[StrumentazioneAttrezzature].FREQUENZATARATURA, \n[dbo].[StrumentazioneAttrezzature].CODIFICA, \nFORMAT(dateadd(day,cast(FREQUENZATARATURA as int)-1, DATAULTIMOCONTROLLO),'yyyy-MM-dd') as DATASCADENZA,\n(case when [dbo].[SCADENZIARIO].STATO=1 then 'Done'\n when [dbo].[SCADENZIARIO].STATO is null then 'None'\n end) as STATON\n\nFROM [dbo].[SCADENZIARIO]\nINNER JOIN [dbo].[StrumentazioneAttrezzature]\nON [dbo].[SCADENZIARIO].ID_STRUM = [dbo].[StrumentazioneAttrezzature].ID\nWHERE [dbo].[StrumentazioneAttrezzature].CODIFICA = (@CODIFICA)","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"","rowsType":"msg","params":[{"output":false,"name":"CODIFICA","type":"VarChar","valueType":"msg","value":"payload","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":1240,"y":1660,"wires":[["ebf23d0a6cf1eceb"]]},{"id":"35ff4baf4828d091","type":"ui_template","z":"84f44064.d1cf4","group":"c33a1024a72aa169","name":"Download Button 1","order":0,"width":0,"height":0,"format":"<button>\n \n <a href=\"/download\">Download Report</a>\n </button>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":2139.4443359375,"y":1759.4443359375,"wires":[[]]},{"id":"dfb4a60f.d788f8","type":"ui_group","name":"Data Export","tab":"48418b79.0f5834","order":1,"disp":true,"width":"12"},{"id":"c33a1024a72aa169","type":"ui_group","name":"Default","tab":"cc6c4310cf7b61cc","order":1,"disp":true,"width":"6","collapse":false},{"id":"6fb70e68d89e36c4","type":"MSSQL-CN","tdsVersion":"7_4","name":"DB_Strumentazione","server":"GIOVANNAQ\\SQLEXPRESS","port":"","encyption":true,"trustServerCertificate":true,"database":"DB_Strumentazione","useUTC":true,"connectTimeout":"30000","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false,"enableArithAbort":true},{"id":"48418b79.0f5834","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1},{"id":"cc6c4310cf7b61cc","type":"ui_tab","name":"TEST","icon":"dashboard","disabled":false,"hidden":false}]
In the Read file node I get the correct path.
Could you please help me?
many thanks