Wednesday, December 17, 2008

How to post SO's or PO's without user dialogs

If you need to update a sales order or a purchase order without any user dialogs, Axapta provides you with a simple interface to do just that.

The SalesFormLetter and PurchFormLetter classes contain the update method, which gives you an easy interface to setup and run posting of a sales order or a purchase order.

The following job is an example on how you use this method to update invoices on sales orders:
static void postSalesFormLetter(Args _args)
    SalesFormLetter  salesFormLetter;
    salesTable  salesTable;

    ttsBegin;  

    while select salesTable
 where salesTable.DocumentStatus < salesid ="=">
 {  
 salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);  // Get a new instance of SalesFormletter
 salesFormLetter.transDate(SystemDateGet());   // Set the invoicedate   
 salesFormLetter.update(salesTable,   // SalesTable                   SalesUpdate::All,  // Quantity to update (SpecQty)                 AccountOrder::None,  // AccountOrder                   false,    // Proforma only?                  true);    // Printout?  }
 ttsCommit;
}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...