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)

Cannot Delete Addresses On LogisticsLocation

(0) ShareShare
ReportReport
Posted on by 15

I try to delete addresses of Customers. And I wrote a job. But I encounter this error :

"Cannot delete a record in LogisticsPostalAddress.

The corresponding AOS validation failed."

Can you help me to about this issue?

My job source code is : 

static void B4D_DeleteAddresses(Args _args)
{

    DirPartyPostalAddressView DirPartyPostalAddressView;
    CustTable custTable;
    str custTableNonDeleted;
    LogisticsLocation location;
    int i;
    ;

    ttsBegin;
    try{
        while select custTable


            {

                while select DirPartyPostalAddressView
                    where DirPartyPostalAddressView.Party == custTable.Party
                          && !DirPartyPostalAddressView.IsPrimary

                            {

                                location = LogisticsLocation::find(DirPartyPostalAddressView.Location,true);

                                 if(location.validateDelete())

                                        location.delete();
                             //   i++;
                            }

            }
    }
    catch(Exception::Error)
    {
       //custTableNonDeleted += custTable.AccountNum + "\n";
        info("Caught 'Exception::Error'.");
    }
   
    ttsCommit;
   // info(strFmt("Customer %1, deleted : %2 ", custTableNonDeleted, i));
}



*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    most probably your address is being used anywhere, you can see a list of table inside postalAddressTableList(method) of LogisticsLocationEntity(Class)

    AX validates if address record is being used, it will restrict you to proceed for deletion.

  • Gokhan B. Profile Picture
    15 on at

    Thank you Sohaib. I fixed the problem.

  • Community Member Profile Picture
    on at
    Could you tell me how the problem solved
  • Gokhan B. Profile Picture
    15 on at

    I put comment characters to postalAddressTableList(method)  = /* method codes */

    So this method was not executed. Because it was restrict ing me to proceed for deletion.

  • Suggested answer
    nc_hwr Profile Picture
    30 on at

    Expiring the record may be a better idea.

    select forUpdate postalAddress where postalAddress.RecId == DirPartyPostalAddressView.PostalAddress;

    postalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
    postalAddress.ValidTo = DateTimeUtil::addMinutes(DateTimeUtil::getSystemDateTime(), -2);
    postalAddress.doUpdate();

  • RohanS Profile Picture
    5 on at

    Hi,

    I am also facing same issue. Can you please let me know what is the changes required?

    Thanks,

    Rohan

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans