How to get all address in AX 2012

Description:-
In this example we will show how to get all address from ax 2012 it could be customer, vendor, bank account, authority address. For that we have to create table so we can save address when we got from job.

Step 1: Create Table Name it “ALLAddresses”. Create Field CustAccount, Address, Name.
  • Expand AOT Node.
  • Open Data Dictionary Node.
  • Select Tables and right Click Select New Table.
  • Name it “ALLAddresses”.
  • Now open table in Insert Some Data in ALLAddresses table.

Create Job from AOT:-

In the AOT, click Job.
Right-click the Job node, and then select New Job. 

static void GettingAllAddresses(Args _args)
{
    CustTable               custTable;
    VendTable               vendTable;
    TaxAuthorityAddress     taxAuthorityAddress;
    LogisticsPostalAddress  logisticsPostalAddress;
    AllAddresses            allAddresses;
    bankAccountTable        bankAccountTable;
    ;
    while select * from custTable
    {
        allAddresses.Address = custTable.address();
        allAddresses.Name = custTable.name();
        allAddresses.CustAccount = custTable.AccountNum;
        allAddresses.doInsert();
    }
    //Getting all vendors
    while select * from vendTable
    {
        //allAddresses.Address = vendTable.address_BR();
        allAddresses.Name = vendTable.name();
        allAddresses.doInsert();
    }
    //Getting all tax authorities addresses
    while select * from taxAuthorityAddress
    {
        allAddresses.Address = TaxAuthorityAddress::address(taxAuthorityAddress.TaxAuthority);
        allAddresses.Name = taxAuthorityAddress.Name;
        allAddresses.doInsert();
    }
    //Getting all bank addresses
    while select * from bankAccountTable
    {
        logisticsPostalAddress = LogisticsLocationEntity::location2PostalAddress(bankAccountTable.Location);
        allAddresses.Address = logisticsPostalAddress.Address;
        allAddresses.Name = bankAccountTable.Name;
        allAddresses.doInsert();
    }
}

Now run your job and see table you will get all address from database.

Related Posts

Previous
Next Post »

Thanks for comments.....