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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to set ValidTo field of logisticspostal address correctly?

(0) ShareShare
ReportReport
Posted on by 625

private void ExpirePreviousAddress(DirPartyRecId party)

{

CustTable custTbl;

DirPartyLocation dirPartyLocation;

LogisticsLocation logisticsLocation;

LogisticsPostalAddress logisticsPostalAddress;

while select dirPartyLocation where dirPartyLocation.Party == party

{

select logisticsLocation where logisticsLocation.RecId == dirPartyLocation.Location;

select forUpdate logisticsPostalAddress where logisticsPostalAddress.Location == logisticsLocation.RecId;

ttsBegin;

logisticsPostalAddress.ValidTo = "3/30/2018 01:15:16pm ";

logisticsPostalAddress.doUpdate();

ttsCommit;

}

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi AXBOY,

    You need to set mode to correction first ValidTimeStateUpdateMode(ValidTimeStateUpdate::Correction);

    private void ExpirePreviousAddress(DirPartyRecId party)
    {
        CustTable custTbl;
        DirPartyLocation dirPartyLocation;
        LogisticsLocation logisticsLocation;
        LogisticsPostalAddress logisticsPostalAddress;
    
        while select dirPartyLocation 
            where dirPartyLocation.Party == party
        {
            select logisticsLocation 
                where logisticsLocation.RecId == dirPartyLocation.Location;
    
            logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction) 
            select forUpdate logisticsPostalAddress 
                where logisticsPostalAddress.Location == logisticsLocation.RecId;
    
            ttsBegin;
            logisticsPostalAddress.ValidTo = "3/30/2018 01:15:16pm ";
            logisticsPostalAddress.doUpdate();
            ttsCommit;
        }
    }
    

    Also you may choose CreateNewTimePeriod period depending on your task, please read for details https://msdn.microsoft.com/en-us/library/gg843767.aspx#Anchor_7

  • AXBOY Profile Picture
    625 on at

    I tried your code..but its giving me error :operand types not compatible with the operator..

    logisticsPostalAddress.ValidTo = "3/30/2018 01:15:16pm ";...on this line

  • Mea_ Profile Picture
    60,286 on at

    I just copied and formatted your code. Yes, you should not assign string to datetime, but your question was not about this. Please follow Sukrub advice and use str2datetime to convert string to datetime.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans