LastModifiedDateTime Has Wrong Datetime Information

 

Hello everybody,

today I want to share interesting use case which raised recently when dealt with syncrhonization of records between Magento and Acumatica.

I had following declaration:

#region LastModifiedDateTime
[PXDBDateAndTime()]
[PXUIField(DisplayName = "Last Modified Date Time")]
public virtual DateTime? LastModifiedDateTime { getset; }
public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }
#endregion

and for my disappointment as well as disappointment of Magento developers we had to add some hours shift to each call, in order to filter out properly by Last modified Date time.

One of the solutions was to add one more flag to attributes in LastModifiedDateTime: UseTimeZone. By default that attribute is set to true, but in my case it was necessary to set it to false:

#region LastModifiedDateTime
[PXDBDateAndTime(UseTimeZone = false)]
[PXUIField(DisplayName = "Last Modified Date Time")]
public virtual DateTime? LastModifiedDateTime { getset; }
public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }
#endregion

After I've made usage of that attribute, values in UI started to display according to what I've seen on db level.

Summary

In case if you see discrepancy between value on db, and UI, and want to have only db level displayed in UI, use flat UseTimeZone set to false.