Many users are aware that in Microsoft Dynamics AX 2012 the session date and time can be changed by going to File > Tools > Session date and time. This can be used to back date transactions and affects the posting date, the source document date and associated due date, and the statistics period in which the current posting journal entire or source document is updated. Refer to this TechNet article: https://technet.microsoft.com/en-us/library/aa571130.aspx. An important point to note in the TechNet article is that the user must sign off the client session in order to reset the session date and time. Once the user changes the session date and time, the session is fixed to that date and time until the user signs off.
Changing session time with X++
It is also possible to set the session date and time using X++. This may be done in order to make use of standard AX functions while back dating transactions. But the same caveat applies. If the session date and time is changed using X++ it affects the client’s session, and the session date and time must be reset or the user may be unaware that the session date and time is suspended. To set the session date and time to a particular value, use the setSystemDateTime method of the DateTimeUtil class:
DateTimeUtil::setSystemDateTime(2016-01-01T14:00:00);
To reset the session date and time use the utcDateTimeNull method of the Global class:
DateTimeUtil::setSystemDateTime(Global::utcDateTimeNull());
Can this cause problems?
It is very important that the session date and time be reset using a null date and time. Otherwise the user’s client session date and time will be suspended at the previous setting, possibly without the user realizing that if this has been done in a background process.