Posting Invoice from Sales order/ Purchase order.

One of the most commonly used classes in AX are the FormLetter classes. The
FormLetter classes define how to post different status updates against sales orders
and purchase orders.
The normal flow when a posting is being performed is that the parm tables are
Populated with data, and then the update itself is performed.
Below example will shows how to Post the Invoice from sales order, similar logics can be used to post the Invoice from Purchase order.

static void postSalesInvoice(Args _args)
// Define a classvariable according to the
// type of posting being performed
SalesFormLetter_Invoice invoice;
SalesTable salesTable;
// Select the salesTable to update
salesTable = SalesTable::find(“SO-101297”);
// Create a new object of the SalesFormLetter_Invoice
// by using the construct-method in SalesFormLetter
invoice = SalesFormLetter::construct(DocumentStatus::Invoice);
// Post the invoice
true); // Set to true to print the invoice

The next screenshot shows the class hierarchy of FormLetter with all its subclasses: we can easily custamize the above logic to post different status updates against sales orders
and purchase orders

Sales (Confirmation, Picking list, Packing slip, Invoice )
Purch (Purchase order,Receipt list, Packing slip, Invoice)


Design Pattern used in Dynamics Ax

I have found the good resource of design patters used in Microsoft Dynamics Ax.

Design Pattern Dynamics ax

Executing SQL directly from X++

The X++ language supports a number of ways to execute native SQL against any SQL data source. Below are two samples for retrieving data as well as manipulating data. Please be aware, that SQL can be really powerful, and it should be used as such.

Example #1: Retrieve data:

Since this example uses a Connecion class, data is retrieved from the database where Axapta is currently connected.

void Sample_1(void)

Connection Con = new Connection();
Statement Stmt = Con.createStatement();

while ( )
print R.getString(1);

Example #2: Manipulating data (deletion):

void Sample_2(void)
str sql;
Connection conn;
SqlStatementExecutePermission permission;

sql = ‘delete from custTable’;
permission = new SqlStatementExecutePermission(sql);
conn = new Connection();
permission = new SqlStatementExecutePermission(sql);
// the permissions needs to be reverted back to original condition.

Happing Daxing J Enjoy the power of SQL using x++

Dynamics Convergence event 2010

The entire Dynamics Convergence event is available now virtually. It’s really fantastically done in much more interactive way. Don’t miss it check it out here….

HomePage Screenshot

Thanks Dynamics Team..that’s really helpful

%d bloggers like this: