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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to get primary active customer postal addresses?

(0) ShareShare
ReportReport
Posted on by 1,552

So if you go to customers in D365, addresses tab - Advanced

you'll be able to see active or history addresses

pastedimage1593680613736v1.png

so right now i have active and history addresses that are all primary.

So if i do the following: i will get 4 primary addresses even though i only have one primary that is active

select  *from CUSTINVOICEJOUR
    inner join CUSTTABLE
        on CUSTTABLE.ACCOUNTNUM = CUSTINVOICEJOUR.ORDERACCOUNT
    inner join DIRPARTYLOCATION
        on DIRPARTYLOCATION.PARTY = CUSTTABLE.PARTY
    inner join LOGISTICSPOSTALADDRESS
        on  LOGISTICSPOSTALADDRESS.LOCATION = DIRPARTYLOCATION.LOCATION
where CUSTTABLE.DATAAREAID = 'usmf'  and DIRPARTYLOCATION.ISPRIMARY=1  and CUSTINVOICEJOUR.DATAAREAID = 'usmf'
    and CUSTINVOICEJOUR.INVOICEID = 'CIV-000001' and CUSTINVOICEJOUR.ORDERACCOUNT = 'de-001'

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi JuniorAx,

    There is a method postalAddress on CustTable record, which will return your primary postal address. Do you think you can use it?

  • MATTGUO Profile Picture
    22,349 Moderator on at

    Add the validto field to filter the active record.

    pastedimage1593685111624v1.png

  • junior AX Profile Picture
    1,552 on at

    Hi Sergie and Matgguo,

    i'm doing this join using data entities, so i'm afraid i can't use the method. So i should put range in the property and say where validTo >= today() ? or what exactly?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi JuniorAX

    Please refer to the documentation on how to make queries for Valid time state table. Also, take into account that LogisticsPostalAddress has time UtcDateTime, so you need to use DateTimeUtil::utcNow() to get the current date and time.

    docs.microsoft.com/.../effects-of-valid-time-state-tables-on-read-and-write-operations

  • Suggested answer
    Rahul Mohta Profile Picture
    21,032 on at

    could try data entity 'customer postal address'

  • junior AX Profile Picture
    1,552 on at

    Hi sergie,

    I think the link didn't help me in data entities. But i tried to put this range logistics postal address validTo field :   >= DateTimeUtil::utcNow()    but it didn't work

  • junior AX Profile Picture
    1,552 on at

    Hi Rahul,

    this one has alot of  joins is there any way to do it with custInvoiceJour,DirPartLocation and logisticsPostsalAddress like i showed above?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Junior_AX,

    There is property on entity itself "Valid time state enabled". You can try to set it to Yes.

    Also you can fetch address via LogisticsPostalAddressBaseEntity, check how it's done for CustCustomerV3Entity (DirPartyBaseEntity->LogisticsPostalAddressBaseEntity)

  • junior AX Profile Picture
    1,552 on at

    Hi Sergie,

    I edited the property to yes and i added validFrom field to the entity key because i got an error that i should add either valid from or valid to.

    i also added this validFrom to the dataEntity Relation in staging table. but i still got all addresses. What am i missing?

    i saw in the data entity u suggested they also used effective field which is validFrom in the entity key.

    btw shouldn't it better to use the 4 tables i made in the data entity instead of the standard one because  the standard ones has alot of datasources?

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Junior Ax,

    How did you test the entity?

    LogisticsPostalAddressBaseEntity itself is a quite light entity and for valid time state entity, you will need to separate address and invoice information, I'm not sure how the entity will behave if you don't have an active address and the whole entity is set as a valid time state is activated.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans