Hi,
I am trying to ceate a script (based on my first script posted here), see below, that should pass 2 or 3 dates to tags which i can use in flows.
However, with setTagValue i get an error that is deprecated and using the suggested alternative it also doesnt work.
What happens… when in the editor it doest work as it should, echo today, tomorrow and an Archument. But when doing it in a flow, it always showing wrong dates, see screenshot. Even when i clear the variable, it comes back with 1 december and 10 september but never with the correct date while it doest show correct date in the editor…
Please help, i dont see it anymore…
Adv_Vandaag = new Date;
Adv_Morgen = new Date;
Adv_Volgendewerkdag = new Date;
//await setTagValue("adv.nldatum.vandaag", {type: "string", title: "adv.nldatum.vandaag"}, Adv_Vandaag);
Adv_Vandaag.setDate(Adv_Vandaag.getDate());
Adv_Vandaag = 'm-d-Y'
.replace('d', ('0' + Adv_Vandaag.getDate()).toString().slice(-2))
.replace('m', ('0' + (Adv_Vandaag.getMonth() + 1)).toString().slice(-2))
.replace('Y', Adv_Vandaag.getFullYear());
Adv_Morgen.setDate(Adv_Morgen.getDate() + 1);
Adv_Morgen = 'm-d-Y'
.replace('d', ('0' + Adv_Morgen.getDate()).toString().slice(-2))
.replace('m', ('0' + (Adv_Morgen.getMonth() + 1)).toString().slice(-2))
.replace('Y', Adv_Morgen.getFullYear());
if (args[0] == '' || args[0] == undefined) {
Adv_Vandaag = GetNlDate(Adv_Vandaag);
//await("adv.nldatum.vandaag", Adv_Vandaag)
await setTagValue("adv.nldatum.vandaag", {type: "string", title: "adv.nldatum.vandaag"}, Adv_Vandaag);
console.log("vandaag: " + Adv_Vandaag);
Adv_Morgen = GetNlDate(Adv_Morgen);
await("adv.nldatum.morgen", Adv_Morgen)
console.log("morgen: " + Adv_Morgen);
return false;
} else {
Adv_Vandaag = GetNlDate(Adv_Vandaag);
await setTagValue("adv.nldatum.vandaag", {type: "string", title: "adv.nldatum.vandaag"}, Adv_Vandaag);
console.log("vandaag: " + Adv_Vandaag);
//await("adv.nldatum.vandaag", Adv_Vandaag)
Adv_Morgen = GetNlDate(Adv_Morgen);
//await("adv.nldatum.morgen", Adv_Morgen)
await setTagValue("adv.nldatum.morgen", {type: "string", title: "adv.nldatum.morgen"}, Adv_Morgen);
console.log("Morgen: " + Adv_Morgen);
Adv_Volgendewerkdag = GetNlDate(args[0]);
//await("adv.nldatum.volgendewerkdag", Adv_Volgendewerkdag)
await setTagValue("adv.nldatum.volgendewerkdag", {type: "string", title: "adv.nldatum.Adv_Volgendewerkdag"}, Adv_Volgendewerkdag);
}
function GetNlDate(inputdate) {
let ArgDate = inputdate.split('-');
let ArgDateEN = new Date(inputdate);
new Date(ArgDate[2] + "," + ArgDate[1] + "," + ArgDate[0]);
var Nr = ArgDateEN.getDate();
const DAYS = ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'];
var Weekdag = DAYS[ArgDateEN.getDay()];
const MONTHS = ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september',
'oktober', 'november', 'december'];
var Maand = MONTHS[ArgDateEN.getMonth()];
inputdate = Weekdag + " " + Nr + " " + Maand;
return inputdate;
}
return(true);