web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Finding customer contacts in AX2012

(0) ShareShare
ReportReport
Posted on by 495

Hello Everyone,

I need some help to extract all customers contact information(specifically telephone numbers) from AX2012R2. I have code to extract one customer by using CustTable::find(custAccount); but I would like to extract all the customers telephone number lets say in a excel sheet or something.

I appreciate all comments and suggestions. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi Lionel07,

    You can use DMFCustomerEntity or DMFCustomerAddressEntity Data Import export framework entity to export all customers with their contact information to csv or other file format.

  • Suggested answer
    startax Profile Picture
    1,845 on at

    static void CustomerContOnAddress(Args _args)

    {

       CustTable                   custTable;

       DirPartyTable               dirPartyTable;

       LogisticsLocation           parentLocation, childLocation;

       DirPartyLocation            dirPartyLocation;

       LogisticsElectronicAddress  electronicAddress;

       LogisticsPostalAddress      postalAddress;

       SysExcelApplication         xlsApplication;  

      SysExcelWorkBooks           xlsWorkBookCollection;

      SysExcelWorkBook            xlsWorkBook;  

    SysExcelWorkSheets          xlsWorkSheetCollection;

    SysExcelWorkSheet           xlsWorkSheet;

    SysExcelRange               xlsRange;  

    CustTable                   custTable;  

    int                         row = 1;  

    str                         fileName;

    ;

    fileName = "C:\\Test.xlsx";

    //Initialize Excel instance  

    xlsApplication           = SysExcelApplication::construct();

    //Open Excel document  

    //xlsApplication.visible(true);

    //Create Excel WorkBook and WorkSheet  

    xlsWorkBookCollection    = xlsApplication.workbooks();   xlsWorkBook              = xlsWorkBookCollection.add();   xlsWorkSheetCollection   = xlsWorkBook.worksheets();   xlsWorkSheet             = xlsWorkSheetCollection.itemFromNum(1);

      //Excel columns captions   xlsWorkSheet.cells().item(row,1).value("Account Num");   xlsWorkSheet.cells().item(row,2).value("Contact");

    row++;      

       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));*/

    xlsWorkSheet.cells().item(row,1).value(custTable.AccountNum);       xlsWorkSheet.cells().item(row,2).value(electronicAddress.Locator);       row++;  

    }

      //Check whether the document already exists   if(WinApi::fileExists(fileName))      

     WinApi::deleteFile(fileName);

      //Save Excel document  

    xlsWorkbook.saveAs(fileName);

      //Open Excel document  

    xlsApplication.visible(true);

      //Close Excel  

    //xlsApplication.quit();  

    //xlsApplication.finalize();

      info(strfmt("Total no of rows imported %1", row));

       }

    }

  • Lionel07 Profile Picture
    495 on at

    hello ievgen, both tables you recommended are empty.

  • Mea_ Profile Picture
    60,284 on at

    You need to run export through DMF and AX will create a file for you, if you are not familiar with DMF read this article docs.microsoft.com/.../user-guide-dixf

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans