Hi,
What would be the correct way to handle process variable of type Date (filled on the Start Process form) mapped to a json field in a JavaScript Script Task?
Regular assignment like json.TestDate = testDate;
causes the TestDate to disappear completely from the new variable, when I execute the code:
var json = {};
json.TestDateString = testDate.toString();
json.TestDate = testDate;
json.TestDateJs = new Date();
json.TestString = testString;
execution.setVariable("asJson", S(JSON.stringify(json)));
execution.setVariable("asString", JSON.stringify(json));
Value of asString variable:
{
"TestDateString":"Wed Jun 23 00:00:00 CEST 2021",
"TestDateJs":"2021-06-22T12:10:40.759Z",
"TestString":"exampleTestString"
}
I’ve tried using replacer or new Date(startDate).toISOString()
or new Date(startDate.toString())
but to no avail.
I’m using Camunda Platform Community v7.14 with Java 8.
I know that Script Tasks are not the best way to use Camunda, but doing it in a Java delegate or an external task is not an option for me.
I would greatly appreciate some help with this.
Example model attached:
date_stringify_issue.bpmn (4.7 KB)