Hello again. Sorry for not attaching the flow (amateur's mistake hahaha).
I am currently using the filename as a var for the nodes and still not working properly
I have also a really strange behaviour when using Global variables: I set a global variable as a flag, and everything goes OK when I do not have a FILE node in my flow. When the flow has this node, the variables disappear...
thanks a lot for your help!
[
{
"id": "542c869f1c352732",
"type": "change",
"z": "842eff3d74e57d5a",
"name": "selectInfo",
"rules": [
{
"t": "set",
"p": "rowCount",
"pt": "msg",
"to": "payload.rowCount",
"tot": "msg"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.rows",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1260,
"y": 3060,
"wires": [
[
"f17c260415820045"
]
]
},
{
"id": "21a3a3a05a70e660",
"type": "postgrestor",
"z": "842eff3d74e57d5a",
"name": "getIncentivesEXT1",
"query": "SELECT *FROM basededatos.beneficiarios;",
"postgresDB": "b18a371b44992e25",
"output": true,
"outputs": 1,
"x": 1070,
"y": 3060,
"wires": [
[
"542c869f1c352732"
]
]
},
{
"id": "f17c260415820045",
"type": "csv",
"z": "842eff3d74e57d5a",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "all",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 1450,
"y": 3060,
"wires": [
[
"65e884b101c40785"
]
]
},
{
"id": "f27a0c87cfc1efb5",
"type": "change",
"z": "842eff3d74e57d5a",
"name": "getReqParams",
"rules": [
{
"t": "set",
"p": "repData.schema",
"pt": "msg",
"to": "pinc",
"tot": "str"
},
{
"t": "set",
"p": "domain",
"pt": "msg",
"to": "config.domain",
"tot": "global"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 800,
"y": 3100,
"wires": [
[
"21a3a3a05a70e660"
]
]
},
{
"id": "65e884b101c40785",
"type": "file",
"z": "842eff3d74e57d5a",
"name": "",
"filename": "",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"encoding": "utf8",
"x": 1610,
"y": 3060,
"wires": [
[
"0645bd9a445147ae"
]
]
},
{
"id": "8c246be2afeceb63",
"type": "change",
"z": "842eff3d74e57d5a",
"name": "setAdHoc",
"rules": [
{
"t": "set",
"p": "busyFlag",
"pt": "global",
"to": "busy",
"tot": "str"
},
{
"t": "set",
"p": "isAdHoc",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 780,
"y": 3060,
"wires": [
[
"f27a0c87cfc1efb5"
]
]
},
{
"id": "0645bd9a445147ae",
"type": "change",
"z": "842eff3d74e57d5a",
"name": "setReady",
"rules": [
{
"t": "set",
"p": "busyFlag",
"pt": "global",
"to": "ready",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "ready",
"tot": "str"
},
{
"t": "set",
"p": "filename",
"pt": "msg",
"to": "./files/busy/status.txt",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1780,
"y": 3060,
"wires": [
[
"7ee79ad9123dab7f"
]
]
},
{
"id": "93837e0327a0025b",
"type": "function",
"z": "842eff3d74e57d5a",
"name": "namingADHOC",
"func": "var ts = new Date();\nvar dateTo = new Date();\nvar thisMonth = dateTo.getMonth() + 1;\nvar thisYear = dateTo.getFullYear();\nvar thisTime = (\"00\" + ts.getHours()).slice(-2) + \"\" + (\"00\" + ts.getMinutes()).slice(-2) + \"\" + (\"00\" +ts.getSeconds()).slice(-2);\nmsg.repData = {};\n\nvar dateFrom = \"01-01-\" + thisYear;\nmsg.repData.taxedDateFrom = dateFrom;\n\n//next lines get the report until \"yesterday\"\ndateTo.setDate(dateTo.getDate() - 1);\ndateTo.setHours(0, 0, 0, 0);\nvar dayTo = dateTo.getDate();\nvar monthTo = dateTo.getMonth() + 1;\nvar yearTo = dateTo.getFullYear();\nthisMonth = (\"00\" + thisMonth).slice(-2);\ndateTo = yearTo + \"-\" + monthTo + \"-\" + dayTo;\n\nmsg.repData.taxedDateTo = dateTo;\n\nmsg.filename = \"./files/adHoc\" + yearTo + monthTo + dayTo + \"-\" + thisTime + \".csv\";\n\nmsg.payload = \"busy\";\n\nreturn [msg, null];",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 620,
"y": 3060,
"wires": [
[
"8c246be2afeceb63"
]
]
},
{
"id": "7ee79ad9123dab7f",
"type": "file",
"z": "842eff3d74e57d5a",
"name": "removeBusy",
"filename": "",
"appendNewline": true,
"createDir": true,
"overwriteFile": "delete",
"encoding": "none",
"x": 1930,
"y": 3060,
"wires": [
[]
]
},
{
"id": "46309b6a126853e3",
"type": "file",
"z": "842eff3d74e57d5a",
"name": "createBusy",
"filename": "",
"appendNewline": false,
"createDir": true,
"overwriteFile": "true",
"encoding": "utf8",
"x": 410,
"y": 3080,
"wires": [
[
"93837e0327a0025b"
]
]
},
{
"id": "44bd59bd0c3ff464",
"type": "function",
"z": "842eff3d74e57d5a",
"name": "nameForBusy",
"func": "\nmsg.filename = \"./files/busy/status.txt\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 420,
"y": 3040,
"wires": [
[
"46309b6a126853e3"
]
]
},
{
"id": "4a03a538e9ee5ea4",
"type": "http in",
"z": "842eff3d74e57d5a",
"name": "POST /files/creation",
"url": "/files/creation",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 130,
"y": 3060,
"wires": [
[
"13a4cd17fd0b9c54",
"44bd59bd0c3ff464"
]
]
},
{
"id": "13a4cd17fd0b9c54",
"type": "http response",
"z": "842eff3d74e57d5a",
"name": "started",
"statusCode": "204",
"headers": {
"content-type": "application/json"
},
"x": 150,
"y": 3100,
"wires": []
},
{
"id": "b18a371b44992e25",
"type": "postgresDB",
"name": "pincDatabase",
"host": "config.dBHostName",
"hostFieldType": "global",
"port": "config.dbPort",
"portFieldType": "global",
"database": "config.dbDatabase",
"databaseFieldType": "global",
"ssl": "false",
"sslFieldType": "bool",
"max": "10",
"maxFieldType": "num",
"min": "1",
"minFieldType": "num",
"idle": "5000",
"idleFieldType": "num",
"user": "config.dBUser",
"userFieldType": "global",
"password": "config.dbPwd",
"passwordFieldType": "global"
}
]