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

Notifications

Announcements

No record found.

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 607

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,284 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
    607 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,284 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans