Expressions Javascript support?

Hi Folks,

I just tried to get new created Items from some project management tool via Interval -> HTTP-Request. To get only new items, I would like to filter the rest call via created_on=>2019-09-27:18:59:100.

I tried to add a FunctionItem to get current time in correct format, but I got stuck setting up the expression. I thought the expression will support full JavaScript, but it seems not. What I tried is:

var d = Date(Date.now());
item.lastCallTimestamp = d.getUTCFullYear() +
‘-’ + pad(d.getUTCMonth() + 1) +
‘-’ + pad(d.getUTCDate()) +
‘T’ + pad(d.getUTCHours()) +
‘:’ + pad(d.getUTCMinutes()) +
‘:’ + pad(d.getUTCSeconds()) +
‘.’ + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
‘Z’;
return item;

However I juts get the error " d.getUTCFullYear is not a function".
Is there any more detailed description how expressions could be used / what is supported?

Thank you in advance!

Br,
Markus

Hello Markus,

yes it supports “full JavaScript” but the problem in that case is that you do not create the d with the type of date you expect it to be. The exact same code would currently also not run in the browser or node.js

This however will:

var d = new Date();
item.lastCallTimestamp = d.getUTCFullYear() +
'-' + pad(d.getUTCMonth() + 1) +
'-' + pad(d.getUTCDate()) +
'T' + pad(d.getUTCHours()) +
'-' + pad(d.getUTCMinutes()) +
'-' + pad(d.getUTCSeconds()) +
'-' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
'Z';
return item;

Ok it will not really work just with that code, as the pad function does not exist, but I assume you have it defined above. And if that is the case it will work.

Ich1Depp… Thank you Jan! Didn’t see it at all :-/

Maybe another thread: Is there a “best practice” for getting new data, except polling for new entries every x seconds? Maybe not an issue in my case, but handling multiple new entries seems getting complicate.
I try to create a NextCloud folder when a new project was created in Redmine.

br,
Markus

You should normally really start a new thread for each now question because else people will not find the question and it complicates the current one.

But very short. Do not know Redmine at all but that gets normally done with webhooks. Guess you can simply create one in Redmine for that and call a n8n webhook node.