Create Free Text Invoice by using X++ in AX 2012

Free Text Invoice is a common functionality required by the organizations. As per Microsoft Technet “A free text invoice is an invoice that is not attached to a sales order. A free text invoice contains a header and one or more lines for items or services that are not tracked in inventory. ”

If you have many Free Text Invoices then adding them manually can be a cumbersome task and therefore, there is a need for automation. Dynamics AX is a powerful ERP and highly customizable so we can utilize that feature of AX.

In this post, I will tell you how you can import multiple Free Text Invoices from Excel using X++.

Create a job or a class as you wish. If you create a class, then add the following code into run method

Import the data from Excel

Lets say we have an excel file with Customer Account, Invoice account, Main account, default dimensions, item code, quantity and the price.

Step 1: Import the data from Excel

By looking at the code, you will get an idea of what type of data is coming from excel file. It is quite straight forward. You have rows and columns (like Customer Account, Invoice Account, main account, item, quantity and some dimensions like department, cost center etc)

 

Step 2: Create ledger dimension record using Main Account

We have to create a record in CustInvoiceTable and it’s lines record in custInvoiceLine table. We need to add a defaultdimension recid in custInvoiceTable. In order to do that we need to create ledgerdimention record first.

We will use the following code to create this record using AxdDimensionUtil

 

Step 3: Create Default Dimensions

The default dimensions in our case are Department, Cost Center and Product Category. The default dimensions are for each line item and so it can be different for each line item or could be same. But we have to create the default dimensions record first and then insert that default dimension record into custInvoinceLine table field ‘defaultdimension’.

 

 

 

Abubaker Siddiq Shekhani

Abubaker Shekhani is an IT Entrepreneur and Full Stack Developer. He is the co-founder and the Developer behind Mytabeeb, a health care solution. He has worked for 5 years in Microsoft Dynamics AX space with Techno-functional role and glad to be one of few Microsoft Dynamics AX developers/consultants in Pakistan. He is TEDx speaker and likes to speak in public. He is an Amateur Astronomer and Astrophotographer. He is the founding member of Karachi Astronomers Society. He can be reached at me@abubakershekhani.com.

You may also like...