SaleDate being set 1 day before today.

lock
push_pin
done
Besvarat
4

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!

18. jan. 2024 | 02:57 em

Allt Svar (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());
18. jan. 2024 | 04:52 em

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.

19. jan. 2024 | 07:19 fm

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?

19. jan. 2024 | 08:00 fm

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.

19. jan. 2024 | 09:23 fm

Lägg till svar