Download file by using HTML link

I'm trying to download a file by a link in a table.
The resulting table is like this:
immagine

I set the path in the table template, and added the 'name' of the attachement coming from an SQL table. Here my flow:

[{"id":"0df67d867ab6de33","type":"debug","z":"2380dbebb998c1d1","name":"Out func 2a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1730,"y":1500,"wires":[]},{"id":"677fc548f7da5acd","type":"MSSQL","z":"2380dbebb998c1d1","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":1700,"y":1420,"wires":[["0df67d867ab6de33","c197fb08b619e2aa","b7161d9eae43e31c"]]},{"id":"c197fb08b619e2aa","type":"link out","z":"2380dbebb998c1d1","name":"Output Table Storico","mode":"link","links":["ccdeee0001de6a66"],"x":1895,"y":1420,"wires":[]},{"id":"b7161d9eae43e31c","type":"ui_template","z":"2380dbebb998c1d1","group":"82829bf25b86e4cd","name":"","order":8,"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=\"/C:\\Datamed\\DB_Strumentazione\\Node-red\\Certificati\\FileStreamDataFile\\{{x.ALLEGATO}}/\" target=\"_blank\"> download </a> \n        </tr>\n    </tbody>\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2080,"y":1680,"wires":[[]]},{"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":"","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false,"enableArithAbort":true},{"id":"82829bf25b86e4cd","type":"ui_group","name":"Storico Date Controllo","tab":"21286fd2ee7bdc0c","order":6,"disp":true,"width":"20","collapse":false,"className":""},{"id":"21286fd2ee7bdc0c","type":"ui_tab","name":"Inserimento Date Controllo","icon":"assignment","order":4,"disabled":false,"hidden":true}]

Maybe I'm wrong in adding the filename (I get it from a query to SQL).

Could you help me to solve it?

Thanks

Have a look at this topic, maybe it can help you.

I followed the post, but I think there is something I'm missing.
Even if a set a fixed name I cannot get the download

An error like this appears:
Cannot GET /C:/...../

You have passed a local file reference rather than a URL.

[{"id":"0df67d867ab6de33","type":"debug","z":"2380dbebb998c1d1","name":"Out func 2a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1950,"y":1360,"wires":[]},{"id":"677fc548f7da5acd","type":"MSSQL","z":"2380dbebb998c1d1","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":1700,"y":1420,"wires":[["0df67d867ab6de33","c197fb08b619e2aa","b7161d9eae43e31c","7b206d637cc3e465"]]},{"id":"c197fb08b619e2aa","type":"link out","z":"2380dbebb998c1d1","name":"Output Table Storico","mode":"link","links":["ccdeee0001de6a66"],"x":1895,"y":1420,"wires":[]},{"id":"b7161d9eae43e31c","type":"ui_template","z":"2380dbebb998c1d1","group":"82829bf25b86e4cd","name":"","order":8,"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=\"/report1\">Download Report</a>\n        </tr>\n    </tbody>\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":1820,"y":1660,"wires":[["1c10caca4ddf9d25"]]},{"id":"1c10caca4ddf9d25","type":"debug","z":"2380dbebb998c1d1","name":"Out template","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2030,"y":1640,"wires":[]},{"id":"14cbec740920cd34","type":"function","z":"2380dbebb998c1d1","name":"Set base path","func":"\nvar basePath = \"/C:/Datamed/DB_Strumentazione/Node-red/Certificati/FileStreamDataFile/\";\nvar filepath = flow.get(\"filename_counter\");\n\n\nif (!filename) {\n    msg.payload = \"No file specified\";\n    msg.statusCode = 404;//not found\n    return [null, msg];//fire output 2\n} else if(filename.includes(\"..\\\\\")){\n    msg.payload = \"Illegal file path\";\n    msg.statusCode = 405;//not allowed\n    return [null, msg];//fire output 2\n} else if(filename.includes(\"../\")){\n    msg.payload = \"Illegal file path\";\n    msg.statusCode = 405;//not allowed\n    return [null, msg];//fire output 2\n} \n\n\n//set msg.filename for the file in node\nmsg.filename = filepath;\n\n//get file name only & add it as the Content-Disposition header\nvar filename = filepath.split(\"/\").pop();\nmsg.headers = {\n    \"Content-Disposition\": `attachment; filename=\"${filename}\"`\n}\n\nreturn [msg, null];//fire output 1\n\n\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1940,"y":1860,"wires":[["d716c36ab3415635","413c0db9fb4922e3"],["91de2a6759eea032"]]},{"id":"91de2a6759eea032","type":"http response","z":"2380dbebb998c1d1","name":"","statusCode":"","headers":{},"x":2150,"y":1940,"wires":[]},{"id":"d716c36ab3415635","type":"file in","z":"2380dbebb998c1d1","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":2150,"y":1860,"wires":[["91de2a6759eea032"]]},{"id":"91082eadc0605907","type":"catch","z":"2380dbebb998c1d1","name":"","scope":null,"uncaught":false,"x":1720,"y":1940,"wires":[["ae06ab5c8b64809f","5b4843bbb489c59a"]]},{"id":"ae06ab5c8b64809f","type":"function","z":"2380dbebb998c1d1","name":"Set 404","func":"msg.payload = msg.error;\nmsg.statusCode = 404;//resource not found\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1900,"y":1940,"wires":[["91de2a6759eea032"]]},{"id":"5b4843bbb489c59a","type":"debug","z":"2380dbebb998c1d1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1730,"y":2000,"wires":[]},{"id":"34bd000011a9f64d","type":"http in","z":"2380dbebb998c1d1","name":"","url":"/report1","method":"get","upload":false,"swaggerDoc":"","x":1710,"y":1860,"wires":[["14cbec740920cd34"]]},{"id":"7b206d637cc3e465","type":"change","z":"2380dbebb998c1d1","name":"","rules":[{"t":"set","p":"payload.ALLEGATO","pt":"msg","to":"filename_counter","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":1700,"wires":[["1717dc4e4921011f"]]},{"id":"1717dc4e4921011f","type":"debug","z":"2380dbebb998c1d1","name":"filename","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1700,"y":1760,"wires":[]},{"id":"413c0db9fb4922e3","type":"debug","z":"2380dbebb998c1d1","name":"Out Path","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2100,"y":1760,"wires":[]},{"id":"6fb70e68d89e36c4","type":"MSSQL-CN","tdsVersion":"7_4","name":"DB_Strumentazione","server":"","port":"","encyption":true,"trustServerCertificate":true,"database":"DB_Strumentazione","useUTC":true,"connectTimeout":"","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false,"enableArithAbort":true},{"id":"82829bf25b86e4cd","type":"ui_group","name":"Storico Date Controllo","tab":"21286fd2ee7bdc0c","order":6,"disp":true,"width":"20","collapse":false,"className":""},{"id":"21286fd2ee7bdc0c","type":"ui_tab","name":"Inserimento Date Controllo","icon":"assignment","order":4,"disabled":false,"hidden":true}]

A more complete flow looking at other post of the forum:

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

Any suggestion?

Many thanks for your help

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