X++ Code to get Address Lookup Based On Purpose D365 FO || Ax2012

Hello everyone, 

In our day to day life we(Developers) always come across address requirements very frequently, so today's post is related to it.  

Fetching customer/Vendor address based on purpose.

public static void customerInvoiceAddresslookup(FormStringControl   _control,
                                                                                  DirPartyRecId          _party)
{
    query                                    query;
    QueryBuildDataSource        qbds;
    SysTableLookup                   sysTableLookup;
    LogisticsPostalAddress        address = null;
    DirPartyLocation                   partyLocation;
    DirPartyLocationRole            partyLocationRole;
    LogisticsLocationRole           locationRole;

    query   = new Query();
    sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsPostalAddress), _control);