get Invoice and delivired Customer Address in dynamics ax

Description:-

In this article we will see about how to get invoice and delivered customer list and write into text file. To get list of all customer and save into text file here is the code to get the customer list with check if Invoice and delivery address is there or not. To save into text file we create text file into destination and run the job in Ax.

Code:-

static void GetInvoice_DeliveryCustomerAddress(Args _args)
{
    Addressing address,address1;
    DirPartyRecId party;
    CustTable CustTable;
    BinData binData,binData1;
    TextBuffer textBuffer,textBuffer1;
    
    textBuffer = new TextBuffer();
    textBuffer.setText('');    
    textBuffer1 = new TextBuffer();
    textBuffer1.setText('');
    
    while select CustTable
    {
      party = CustTable::find(CustTable.AccountNum).Party;
      //Invoice
      address = DirParty::getPostalAddressByType(party,LogisticsLocationRoleType::Invoice);
      //Delivery
      address1 = DirParty::getPostalAddressByType(party,LogisticsLocationRoleType::Delivery);
      //If get Invoice and delivery Checked
      if (address && address1)
      {
          textBuffer.appendText(strfmt('%1\r\n',CustTable.AccountNum));
      }
      //If get Invoice and delivery NotChecked
      else if(!address && !address1)
      {
          textBuffer1.appendText(strfmt('%1\r\n',CustTable.AccountNum));
      }
        
      textBuffer.getText();
      binData = new BinData();
      binData.setStrData(textBuffer.getText());
      binData.saveFile(@"Text File Location");
        
      textBuffer1.getText();
      binData1 = new BinData();
      binData1.setStrData(textBuffer1.getText());
      binData1.saveFile(@"Text File Location");
    }
}

Note:- Here I have get customer address like invoice and delivery. if you want selected only one then you can put || (OR) condition. One customer have selected for invoice and another customer has delivery checked and in Code if you have put || (OR) condition then you can get both customer.

Related Posts

Previous
Next Post »

1 comments:

comments

Thanks for comments.....