web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Timestamp milliseconds trimmed in DIXF bug in D365?

(0) ShareShare
ReportReport
Posted on by 1,159

Hi Techies,

I have created a composite entity in D365 fno and have added an utcdatetime field as part of the primary key known as timestamp.

The primary key is "sales id " + "timestamp".

The timestamp will always be different however the sales id can get repeated multiple times.

We have created a recurring batch API to integrate records from 3rd party to D365 and vice versa.

Problem : When the users sends multiple records with difference in timestamp( in milliseconds) the flow gets into primary key voilation however there is no primary key violation as per the data. In fact the milliseconds are trimmed before getting into staging and hence it considers 2 different timestamp as same and hence gives an error.

eg. Timestamp1 = "18/08/2015 06:30:15.606     and timestamp2 = "18/08/2015 06:30:15.706"

Also note that I have just imported a single record and it got imported so there is no other issue apart from the milliseconds getting truncated which then violates the primary key.(sales id is the same for both records.

Timestamp1 value in the staging table after single record import is "18/08/2015 06:30:15.000"

As you can see that the difference is in milliseconds but then too the system gives an error and it does not even creates any record in the staging tables.

Can you please help me sort this issue ?
Why D365 trims the milliseconds while importing into the staging tables ? Is there a way I can fetch the correct data before it gets truncated in the staging tables.

Thanks,

Vikas Mehta.

I have the same question (0)
  • Alex VN Profile Picture
    1,994 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Hi,

    I believe currently AX does not handle milliseconds for time, you can refer to this document:

    community.dynamics.com/.../449787

    For this issue, I would recommend you to convert the time to string then save it in the field for comparision purpose.

    Hope this helps.

    Anh Ong.

  • Vikas Mehta 21 Profile Picture
    1,159 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Thanks Anh

    I have seen that link.

    I want to get the milliseconds from the incoming record and not create a milliseconds .

    Also what are the methods that I should look for the conversion part

  • Alex VN Profile Picture
    1,994 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Hi,

    I think you can try to use WinAPI::getTickCount(); as suggested in the same thread above.

    Regards,

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    D365 stores UtcDateTime timestamp only on accuracy of seconds, not milliseconds. So you can't use the timestamp as an unique key if you have many entries on the same second.

    You would need to store the milliseconds in another field and use that as part of your unique index.

  • Vikas Mehta 21 Profile Picture
    1,159 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    The WinAPI::getTickCount() retrieves the number of milliseconds that have elapsed and it wont help me get the milliseconds from the given string .

  • Vikas Mehta 21 Profile Picture
    1,159 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Hi Nicolas,

    How do i store the milliseconds before it gets saved in the staging table? I mean which methods will give me the records value before inserted in the staging tables as I believe that the error is coming before hitting the insert methods of staging tables and is coming via the DMFExecuting classes.

    I tried to convert a sample value in a job using system.datetime but it seems there is some limitations.

    kindly revert with some ideas

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Since D365 will always discard those milliseconds in the timestamp field, you have to send them in another field. Your entity should have an integer field, and then the sender (or your integration platform, doesn't matter to D365) should put the milliseconds there.

  • Vikas Mehta 21 Profile Picture
    1,159 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Thanks Nikolas,

    So i will have to change the primary key to (timestamp + millisecondsCOL(INT))

    where millisecondsCOL is a new integer field and combination of this will be the new primary key for the staging tables..

    I was also thinking of a new  string field and consider it as the new primary key as it will be unique.

    Thanks for your suggestion.

    I still have a question whether we can change the value of a field which is getting failed at the primary key violation at staging table level ?

    It is quite strange that this scenario is having no way to handle the values of the records.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    You can try to put code validateWrite() or insert() methods of the staging table and see if the execution goes that far before the primary key issue happens. But I suggest to post a new question (or search for existing discussions) if you wish to discuss that topic deeper.

  • Vikas Mehta 21 Profile Picture
    1,159 on at
    RE: Timestamp milliseconds trimmed in DIXF bug in D365?

    Ok I will write  a new post on this part .

    I have checked and the debugger does not stop at validateWrite or insert() method.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,047

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 885 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 592 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans