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 get customer (CustAccount) from postal address (LogisticsPostalAddress).

(0) ShareShare
ReportReport
Posted on by 120

I have a scenario, where I know the LogisticsPostalAddress.RecId, from this I need to find the customer (CustTable.AccountNum) it belongs to.
I have identified the table relations and can write a select query.

If there is a better way of getting customer by using standar AX functions then please suggest.

*This post is locked for comments

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

    Hi OSMHN,

    You can use DirPartyPostalAddressView it has _recVersion_LogisticsPostalAddress field and Party, using Party field you can easily find customer.

  • MSKAX Profile Picture
    120 on at

    Thanks Sukrut

  • MSKAX Profile Picture
    120 on at

    Hi Ievgen,

    I have written job as below: I am considering using DirPartyPostalAddressView, there must be advantages of that view, I am not aware....

    static void Address_LogisticsPostal_update(Args _args)

    {

       LogisticsPostalAddress  logisticsPostalAddress;

       LogisticsLocation       logisticsLocation;

       DirPartyLocation        dirPartyLocation;

       DirPartyTable           dirPartyTable;

       CustTable               custTable;

       DirPartyPostalAddressView   dirPartyPostalAddressView;

       // assume, this record is being updated

       logisticsPostalAddress = LogisticsPostalAddress::findByLocation(5637176076); //Location - 5637176076

       logisticsLocation = LogisticsLocation::find(logisticsPostalAddress.Location);

       select * from dirPartyLocation

           where dirPartyLocation.Location == logisticsLocation.RecId;

       dirPartyTable = DirPartyTable::findRec(dirPartyLocation.Party);

       custTable = CustTable::findByPartyRecId(dirPartyTable.RecId);

       //dirPartyPostalAddressView = DirPartyPostalAddressView::find(dirPartyTable.RecId, logisticsLocation.RecId);

       //custTable = CustTable::findByPartyRecId(dirPartyPostalAddressView.Party);

       info(strFmt("Done. AccountNum -  %1", custTable.AccountNum));

    }

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    You can write instead:

    select Party from dirPartyPostalAddressView

    where dirPartyPostalAddressView.Location == 5637176076;

    custTable = CustTable::findByPartyRecId(dirPartyPostalAddressView.Party);

  • MSKAX Profile Picture
    120 on at

    Thanks Ievgen.

    Its a very valuable contribution by you and other experts on this forum. Feels great.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    If you issue is solved please mark answer(s) that helped you as verified to close this thread.

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