Create Sales Order Lines from outside SalesOrder Form


I want to create a sales order from .net into AX.The sales header is getting inserted wihout any problem.But when i try to insert into SalesLine an error applied for filling the Currency,Group,Customer,Requested ship date.

Although they were filled in the header creation.

I tried the following code

public boolean insertPurchLine(
ItemId _itemId, CostPrice _costPrice,
Qty _qty, ItemFreeTxt _text = “”)
InventTable item;
salesLine.SalesId = salesTable.SalesId;
item = InventTable::find(_itemId);
salesLine.ItemId = item.ItemId;
salesLine.Name = item.ItemName;
salesLine.SalesPrice = _costPrice;
salesLine.SalesQty = _qty;
salesLine.LineAmount = salesLine.calcLineAmount();
salesLine.LineNum = salesLine::lastLineNum( salesLine.SalesId) + 1;
return true;


Kindly Help…

Hi Anderson,

I guess you referred to this article ( in your code.

Have you made any customisations to SalesLine table → initFromSalesTable (OR) SalesLineType class → initFromSalesTable method?

The other option I can think of is change parameters to SalesLine table → CreateLine method.


Hi harish,

I have not done any customizations to SalesLine table or init methods.

I tried passing different parameters to createLine method also but the same error is repeated.

Im not able to insert into salesline table…

Once again can you type the total error…



Hi Anderson,

Create a standard Ax job for creating sales order and line (basically replicating what you are trying to do using .NET Business Connector). Add a breakpoint on info class → add method and run the job. This should point the error source. Please let us know the source.

Also please post the entire error message.



I tried in jobs. The sales header and line is getting inserted with no errors.

Thanks for the help .

Hi Anderson,

The code seems right.

Just check, whether you are getting the reference of salesTable or not.

Hi Manish,

Thanks for your reply…

Im able to insert the salesline now from .net…