Getting Vendor addresses based on Address type in AX 2012 R2/R3

The following query gets the vendor addresses

 select ROW_NUMBER() over (partition by v.accountNum order by dpl.isprimary desc, lpa.recid) as AddressNumber,v.ACCOUNTNUM,lpa.ADDRESS,llr.NAME from VENDTABLE V
 join DIRPARTYLOCATION Dpl on v.party=dpl.party  and dpl.ISPOSTALADDRESS=1
 join LOGISTICSPOSTALADDRESS lpa on dpl.LOCATION=lpa.LOCATION  
 join DIRPARTYLOCATIONROLE dplr on dplr.PARTYLOCATION=Dpl.RECID
 join LOGISTICSLOCATIONROLE llr on dplr.LOCATIONROLE=llr.RECID
 where llr.TYPE=10 — Can be any type as per requirement

Advertisements