Skip to main content

Notifications

Microsoft Dynamics AX forum

Finding the correct record in the table Address table from Sales Order

Posted on by Microsoft Employee

Hi,

I am trying to pick out some fields from the Address table which are related to a sales order and I'm struggling to find the relationship and how to bring up the correct fields in my form.

As an Example say you have SO which has a delivery address. The Address table has the field phone and I'd like to display this on my form for the address selected in the SO.

However there can be multiple addresses with the same value in the "address" field, how would I pick up the correct one? I can't seem to find the unique relationship between the two.

 

Thanks

-Howard

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 229,067 Most Valuable Professional on at
    Re: Finding the correct record in the table Address table from Sales Order

    @HowardWebb: AddressRefTableId and AddressRefRecId contains actual TableId and Recid, not a reference to AddrTableId and AddrRecId fields.

    It can be a record from either Address or CustTable.

    @Kent: Although SalesTable as a database object has a reference to just one address, sales order as a logical object can have several delivery addresses, because each line can be send to a different address.

    And a primary delivery address from CustTable is just a default value and doesn't have to be used for a particular sales order.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Finding the correct record in the table Address table from Sales Order

    DeliveryAddress is copied over from Address table.  The methods you mentioned.  There is a 1:1 on this because salesTable only has one dlv address.

    Question is why are you going from address table to salesTable?  

    All addresses link back to global address book...  Take the salestable, link it back to the customer and then link the customer to the address table.  AddrTableId is 77(custTable) with your customer recId being addrRecId.

    I'm sure there is another way to do this but SalesTable does not have a DeliveryAddressPhone field.  What you can do is modify SalesTable to include this field and then copy the values over in the setAddress / initFromCustTable methods.

    Hope this helps... somewhat.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Finding the correct record in the table Address table from Sales Order

    Thanks for the reply - and sorry for the delay. Firefox was having issues with the site!

    Looking at the address table I can see that there are multiple lines with the same values in "AddrRecId" and "AddrTableId" as finding the first will not do I need to somehow find the one and only record that is linked to the SO. Looking at SalesTable I can see that there is a method called "setAddress" which seems to map the AddressRefRecId to the RecId on the Address table. But I can see some records that don't fit. I might have some junk data as there has been a lot of work in this area. Am I on the right path?

    Thanks again!

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 229,067 Most Valuable Professional on at
    Re: Finding the correct record in the table Address table from Sales Order

    There is a relation over SalesTable.AddressRefTableId and SalesTable.AddressRefRecId fields. But don't forget that the same exists on SalesLine level too (for shipments to multiple addresses).

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

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,782 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,067 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,150

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans