Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / same createdDateTime w...
Finance forum
Unanswered

same createdDateTime when creating records

Posted on by 254
Hi,

How can I make sure that I insert two records in the same table, and these two records have exactly the same createdDateTime? even if i do it in the same transaction would that gurantee that those two records will always have the same exact createdDateTime?
  • Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    same createdDateTime when creating records
    Could you react to my first question, please? As far as I know, change tracking isn't based on CreatedDateTime, therefore you seem to be solving a wrong problem.
     
    The change tracking table will be updated when the transaction is committed. If you create both orders in the same transaction, they (and their change tracking entries) will became visible to the rest of the system at the same time (when the transaction gets committed).
     
    Do you have some tests that prove me wrong?
     
    CreatedDateTime isn't available in all tables and it doesn't have any information about updates, which change tracking takes into account.
     
    Regarding your example, you're saying that you created SO2 and SO3 at almost the same time, but then you're saying that you want to export different orders together: SO3 and SO4. To me, it sounds like a very different scenario than what we discussed so far. You talked about orders created in the same transaction at the same time, while SO3 and SO4 were created twenty seconds apart. The fact that you created SO4 before SO3 and SO2 sounds suspicious too.
     
    Which orders did you create in the same transaction?
     
     
  • Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    same createdDateTime when creating records
    As far I know, change tracking utilizes SQL Server Change Tracking, not CreatedDateTime field. Am I mistaken?
     
    IsLinked and CreatedDateTime doesn't sounds like a reasonable link of the related orders to me. You should use a SalesId reference, or a separate link table (especially if there may be more than two related orders).
     
    If you use a field for the SalesId reference, you also don't need to create any "dummy" field.
  • Anthony Blake Profile Picture
    Anthony Blake 1,957 Super User 2024 Season 2 on at
    same createdDateTime when creating records
    As you've found, the Created Date Time isn't a field you can guarantee will be the same across records, so why not just add a custom field. You can treat it however you would like
  • Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    same createdDateTime when creating records
    Please explain what business problem you're trying to address, so we can suggest a better solution. The solution you chose is impossible to implement. If records are inserted a second apart, the fact that you see one second difference in CreatedDateTime is the correct behavior and you can't change that.
  • Anthony Blake Profile Picture
    Anthony Blake 1,957 Super User 2024 Season 2 on at
    same createdDateTime when creating records
    I would use an additional field so that you have control over the contents. CreatedDate/Time can then continue to work as it is supposed to.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans