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 :
Microsoft Dynamics AX (Archived)

How does ValidTimeStateUpdate for valid time state tables work?

(0) ShareShare
ReportReport
Posted on by 2,460

So I have been playing around with valid time state tables and the date effective features in AX 2012. On form datasources one can set the property "ValidTimeStateUpdate". The possible values and their meaning are described as:

* CreateNewTimePeriod – A new record is inserted into the table to maintain the validity of the date effective data after the update_recordset statement completes.
* Correction – The ValidFrom or ValidTo values of existing rows must be modified to keep the date effective data valid after the update_recordset statement completes.
* EffectiveBased – Records in the past cannot be edited. Records that are currently active are edited in a manner similar to CreateNewTimePeriod mode. Future records are edited in a manner similar to Correction mode.

I tried to figure out scenarios to show the differences between the 3 values, but was unsuccessful. I'm especially interested in "CreateNewTimePeriod", which is supposed to create new records. Has anyone seen a scenario where that is the case?

I read through
http://msdn.microsoft.com/en-us/library/gg841023.aspx
and
http://msdn.microsoft.com/en-us/library/gg843767.aspx
and the Web Seminar provided here
https://training.partner.microsoft.com/learning/app/management/LMS_ActDetails.aspx?UserMode=0&ActivityId=742581
but could not find an answer.

*This post is locked for comments

I have the same question (0)
  • jaestevan Profile Picture
    1,719 on at
    RE: [AX2012] How does ValidTimeStateUpdate for valid time state tables work?

    The question is quite old but if any is interested... the records are really inserting but the form is showing only active data. If you run a Jof exploring all the dates (or explore throug SQL Server table) you'll see the new versions created for each change.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: [AX2012] How does ValidTimeStateUpdate for valid time state tables work?

    "CreateNewTimePeriod" is actually used often.  The best way to understand the differences is to apply a scenario to it.  I'll use some made up examples/numbers.

    You have a customer A with one active address record:

    LogisticsPostalAddress.Address = "123 South St, Chicago, IL"

    LogisticsPostalAddress.RecId =52565480000;

    LogisticsPostalAddress.ValidFrom = DateTimeUtil::minValue();

    LogisticsPostalAddress.ValidTo = DateTimeUtil::maxValue();

    Let's say you have a SalesOrder SO123 that you shipped to Customer A at address "123 South St, Chicago, IL" (RecId 52565480000) on 1/1/2016.

    Later, the customer calls you and asks you to update their address to "321 North St, Chicago, IL".  Well for audit/history purposes, whenever you look at SO123's packing slip, you want to know it was shipped to 123 South St. So CustPackingSlipJour.DeliveryPostalAddress = 52565480000.

    When you update the 52565480000 record, the state is by default "CreateNewTimePeriod", and when you save the record it does an Update then Insert, where the update expires 52565480000 (ValidTo = DaetTimeUtil::utcNow()), and the insert creates a new record with [ValidFrom = DateTimeUtil::utcNow(); ValidTo = DateTimeUtil::maxValue();]

    "Correction", would be if you wanted to change an address and have it be persisted everywhere that the address was used, or sometimes when you're working with an address record, it's saved at various points and you don't want to keep creating new records when the user isn't finished working with it.

    "EffectiveBased" means that if you wanted to modify both expired records (where .ValidTo < utcNow()) and effective/active records (where .validFrom()<=utcNow() && .validTo()>=utcNow()) in some sort of process, then it'll do "Correction" actions when the record is still an effective date, but will do CreateNewTimePeriod and create a new address record when it's no-longer active to persist historical addresses.

  • Community Member Profile Picture
    on at
    RE: How does ValidTimeStateUpdate for valid time state tables work?

    Hi AlexDAX,

    The first time I'm confuse in this situation too, but I've understood with your explanation

    But I would like to ask you the question that relative to code (X++), Is there any way to get the record that have just updated (and cause one more record insert) use RecID ?

    I select to get RecID of update record, and use code

    SELECT logisticsPostalAddress
    WHERE logisticsPostalAddress.RecId == [RecID]


    but that can't get info of record.

  • Suggested answer
    jaestevan Profile Picture
    1,719 on at
    RE: How does ValidTimeStateUpdate for valid time state tables work?

    X++ wise there is no "new" record, this is part of the implementation but with a regular select you will only the record that satisfies the filter, including the Valid* dates regarding this framework (or the implied filter if you don't specify them).

    You can see the SQL final statement to understand it better.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans