SaleDate being set 1 day before today.
Hello,
We have identified recently, that a script in our system responsible for setting the SaleDate to today's date for sales with a status other than 1(open) is not working as intended.
Upon closer inspection, we observed that after correctly setting the sale date, there is an unexpected step where it is subsequently decremented by one day.
I've conducted a thorough check to ensure that no other scripts are conflicting or overlapping with the one in question.
This script is the sole instance where the SaleDate is manipulated.
This issue has only surfaced recently, as it was functioning as intended at least until December.
Both our Production and Test Environments are exhibiting the same problematic behavior and both are on the same build (Build: Release_10.2.11_2023.12.18-02)
Here is a stripped-down version of the script we are running, which is producing the same results.
Tracing the script, today yields the following date, which should be inserted.
#setLanguageLevel 3;
EventData ed = getEventData();
String saleStatus = ed.getInputValue("SaleStatus");
String saleDate = ed.getInputValue("SaleEntity.Saledate");
String curDate = getCurrentDate().toString();
DateTime currentDate = curDate.toDateTime();
String currentDateConverted = currentDate.toString();
If (saleStatus != "1"){
ed.setOutputValue("SaleEntity.Saledate", currentDateConverted);
}
Any help would be greatly appreciated!
Thank you!
Alle Antworten (4)
Hi Andrei,
I tried on my SOD tenant but I can't replicate your issue.
What happens if you just specify a date instead of a datetime?
ed.setOutputValue("SaleEntity.Saledate", getCurrentDate().toString());
Hello David,
That seems to be working, so the issue is with dateTime.
When I initially made this work I've had some issues setting the dates, the reason why its converted to DateTime.
For some reason this was the only way to make it work.
Would you know why its substracting a day, after it sets the correct day?
Was thinking that it may attempt to round it, but to the previous day would not make much sense.
Hi Andrei,
Only thing I can think of that is has to do with timezones and since you are passing a date with time component that it is trying to convert it to UTC.
Are timezones enabled in your tenant?
Hello David,
I see that only Norway is active.
The script was activated in early December, and testing did not yield this type of behavior.
Only recently I've noticed this.