Return datetime object in function


I am trying to return a datetime object using a function. However the debugging tool tells me I return the wrong format. After searching for what causes the error I believe it might be something with the Date vs Datetime in JavaScript. Has anyone encountered this problem? If so how can I solve it?

Screenshot 2023-03-08 114629

Thank you!

In Appfarm functions, you can only return primitive types, such as: string, boolean, number, etc.

and here, you are returning a Date object. Maybe you want to return a string formatted as a date instead?

Ok, I see!

My wish is to set a datetime field of an object using the Create Object action node. I guess I’ll have to find a work around using the value processor maybe.

1 Like

Appfarm’s date property is an ISO formatted date string. You will get the correct format by doing a .toJSON() on a date object.

In your case: return startDate.toJSON()

1 Like

This error message is now documented (and searchable) in our docs.