Wednesday, August 16, 2017

How to find previously used addresses or other older records in Valid Time State Tables for Date Effective Data in Microsoft Dynamics 365 or AX

In Dynamics (AX/365) there is a concept of "Valid Time State Tables" that contain date effective data.  In this post, you'll find code to list all the previous addresses tied to an individual record.

If you are not familiar with this type of data, the simplest example to wrap your head around is postal addresses. If you are, just skip the next paragraph.

Let's say you send an order/invoice to a customer at 123 South St on 1/1/2017. Then a few months later, the customer moves locations to 456 North Ave and you update their address in Dynamics. All is good so far. Then for some reason you need to reprint the 1/1/2017 invoice...well that address record for 123 South St still exists in the database, but it's "ValidTo" is in the past. This way you have the historical addresses.

This sample job below takes an address and loops through the older versions of that address. This method can be used to seek any data in valid time state tables though.

static void AlexOnDAXFindOldAddresses(Args _args)
    CustTable                       custTable = CustTable::find("ZZZZ");
    LogisticsPostalAddress          logisticsPostalAddress;
    LogisticsPostalAddress          logisticsPostalAddressOld;
    utcDateTime                     utcMinVal = DateTimeUtil::minValue();
    utcDateTime                     utcMaxVal = DateTimeUtil::maxValue();
    // Active address
    logisticsPostalAddress = CustTable.postalAddress();
    info("Current: " + logisticsPostalAddress.Address);
    setPrefix("Previous Addresses");
    // This will loop through the inactive addresses in order
    while select validTimeState(utcMinVal, utcMaxVal) logisticsPostalAddressOld
        order by ValidTo desc
        where logisticsPostalAddressOld.Location        == logisticsPostalAddress.Location      &&
              logisticsPostalAddressOld.RecId           != logisticsPostalAddress.RecId
        info(strFmt("%1 [%2-%3]",


  1. i am a dummy when it comes to these kind of studies or tasks. i am glad i got to this post and had it made way too easy for me. thank you so much for posting. keep us updated

  2. First time user , service fantastic , was delivered 2 hrs after order placed . Will be using again Europa-Road Kft

  3. Indian 3d Product Design Company & 3d Product Design Services
    Quickgunz Pvt Ltd offer many 3D Product Design Services or artist impressions for the architectural, advertising, engineering, medical industry and people who insists to require our quality 3d product Design’ help and services to place their competitors can view our services, samples of 3d animation, modeling, illustrations and merchandise visualizations.To know more about our 3D product Design company Visit our website.
    3d Product Design
    3d Product Design Company


  4. We are Offering For Vip Clients With Five Star Hotel Hi Profile Model Call center escorts in Delhi Airhostess, Celebrity Independent Escorts Available in Delhi. If You are Success Your Dream Enjoy With Hi Profile Delhi escorts and Like Actress Great Feeling and Awesome Satisfaction Contact hot escorts in Delhi We Have Original and Decent Escort Service in Shangrila Hotel Delhi. Very Attractive, Frank and Friendly Behavior Best Call Girl Services in Delhi. Looking for some fun in between the monotonous schedule of work? Welcome to Top 7 Escorts in Aerocity for the fun that you always wanted in between your hectic schedule. The young and charming teen escorts in Aerocity are just a call or an e-mail away at your service. Also there are a very few of escort agencies who are providing ebony escorts in Delhi or in other words Black escort girls in delhi. In foreigner escorts Black girls are most demanded now a days

  5. I imagine that you should now like a casino that can satisfy you with its extremely extraordinary achievement. I feel that you would be exceptionally intrigued, at that point you should begin to play in a casino that can help and enjoyment you with extraordinary delight. No one but you can casumo casino review significantly take bring in cash on playing at the casino


  6. Emblix Academy – Digital marketing institute in KPHB, we address all major and minor aspects required for any student’s advancement in digital marketing. Clutch USA named our Digital Marketing Institute the best SEO firm. for more info visit here :-

  7. My marriage crashed about two years in the past and I tried all I may want to inside my powers to restoration it however to no avail. I noticed distinct posts and stories about the precise matters Dr. Larry has been doing so I determined to provide it a try. Though he is continually a busy man, when he replied again to my email, he gave me forty eight hours for my marriage to be restored, and simply like he stated my marriage was once restored, given that then I am completely happy and I am dwelling fortunately in my marriage.

    Visit Our Service Link:-
    Sexy Girls
    Spa Girls
    Independent Dating Girl
    High Class Adult Service

  8. By clicking on the link, you can see a variety of postcards for your beloved stepmother. Thus, you can order flower delivery on the same site along with postcards. If anything, you can also buy gift boxes or pour it yourself, which is very, very convenient. In general, please your loved ones and never quarrel!

  9. Fantastic news everyone, I think for people who can now get a tattoo for themselves, you can use a splendid site bat tattoo design ideas there you can quickly pick a specialist for yourself who will play out everything and photo work for which there is a phenomenal opportunity to pick an organized able.

  10. Kasyno online to normalna strona do grania, sam czasami gram tam na automatach, jeśli uda mi się wygrać, pieniądze są najczęściej wypłacane tego samego dnia, więc kasyno online wszystko jest bez oszustwa, osobiście przeze mnie zweryfikowane. Możesz więc sam spróbować tam zagrać.

  11. Everything considered I saw one charming article about how Connect Amazon S3 to WooCommerce . I figure the information will be appropriate for individuals who somehow need to start working with Amazon. For example, this will be essential for vendors on the Amazon site, since you can learn new commonly secret methodologies that can make your life and usage of the stage more straightforward.

  12. Nice to see you! You can hire a subject professional for any type of work. Our esssy writer specialize across all subjects and academic levels. Their profound expertise is the key to brilliant results and fast delivery. Any task is do-able with their pro help. That is why we do our best to improve the services we provide and make sure we are able to meet our customers’ demands every single time they place an order.