Skip to main content

Notifications

Announcements

No record found.

X++ code to retrieve contact information on customer Address in AX2012

Hi,

Below code helps us to retrieve the various types of contact information specified on customer address.

Contact Information on Customer:

CustContactInfo.png

static void CG_CustomerContOnAddress(Args _args)
{
    CustTable                   custTable;
    DirPartyTable               dirPartyTable;
    LogisticsLocation           parentLocation, childLocation;
    DirPartyLocation            dirPartyLocation;
    LogisticsElectronicAddress  electronicAddress;
    LogisticsPostalAddress      postalAddress;

    while select custTable
        where custTable.AccountNum == "XYZ" //Specify customer account
        join dirPartyLocation
        where dirPartyLocation.Party == custTable.Party
        join parentLocation
        where dirPartyLocation.Location == parentLocation.RecId
        join postalAddress
        where postalAddress.Location == parentLocation.RecId
        join childLocation
        where childLocation.ParentLocation == parentLocation.RecId
        join electronicAddress
        where electronicAddress.Location == childLocation.RecId
        //&& electronicAddress.Type == LogisticsElectronicAddressMethodType::Phone //Type Phone
    {
        info(strFmt("Customer: %1, PostalAddress: %2, RoleType: %3, contact description: %4",  custTable.AccountNum, parentLocation.Description, electronicAddress.Type, electronicAddress.Description));
    }
}

Output:

Output.png

Regards,

Chaitanya Golla

Comments

*This post is locked for comments