All Addresses Related to a Customer

Hi All,

How to find All Addresses(Including Primary Address) Related to Particular Customer(Ex.CustAccount-1101) in Ax 2009 ?

Tell me the possibilities…

Thanks in Advance…

static void Customer_All_Address_AX_5_0_Ver(Args _args)
{
Address address;
DirPartyAddressRelationshipMapping relationshipMapping;
DirPartyAddressRelationship addressRelationship;
DirPartyTable partyTable;
CustTable custTable;
RefTableId custTableId, dirPartyTableId;

;
custTableId = tableNum(CustTable);
dirPartyTableId = tableNum(DirPartyTable);

while select address
where address.AddrTableId == custTableId ||
address.AddrTableId == dirPartyTableId
exists join relationshipMapping
where relationshipMapping.RefCompanyId == address.dataAreaId
&& relationshipMapping.AddressRecId == address.RecId
exists join addressRelationship
where addressRelationship.RecId == relationshipMapping.PartyAddressRelationshipRecId
exists join partyTable
where partyTable.PartyId == addressRelationship.PartyId
exists join custTable
where custTable.PartyId == partyTable.PartyId
&& custTable.AccountNum == ‘C000000001’ // to do pass the Customer accountnum
{
info(address.Name);
}

}

You can get it from Address table. Have a look at the relation with CustTable in Address table.

Hi Saadullah,
Thanks for ur reply…Its working…

Hi Kranthi,
Thanks for ur reply…U r always provide the ways to do the task…Thanks for ur guidance and way of responding…