When this error occurs ?
When auto generating Sales Orders in IND Localization through code in AX2012, system will not allow confirmation or proceeding further with the SO and will through error "TIN number must be filled in"Why this error ?
This error occurs due to unhandled cases not considered for India localization. SalesLine_IN is the IND localization table for Sales Order in AX 2012 where the India tax related mandatory information is stored. Default Sales Order creation code for e.g. SalesLine.createline(1,1,1,1,1) fails to insert required mandatory data in SalesLine_IN.Solution
Override the insert() table-method in SalesLine_IN as follows:
public void insert()
{
if (this.SalesLine != 0)
{
// only insert if the Foreign key is valid
this.initValue();
super();
}
}
{
if (this.SalesLine != 0)
{
// only insert if the Foreign key is valid
this.initValue();
super();
}
}
Now use any standard code for sales line creation, which will succeed without any error during execution. One sample code, that I use is as follows ->
############################################
AxSalesLine axSalesLine = new axSalesLine();
SalesLine salesL;
salesTable salesT = salesTable::find(_salesId);
real price = 99.99;
itemid item = "1001";
qty qty = 4;
;
SalesLine salesL;
salesTable salesT = salesTable::find(_salesId);
real price = 99.99;
itemid item = "1001";
qty qty = 4;
;
salesL.initFromSalesTable(salesT);
salesL.initValue(SalesType::Sales);
salesL.initValue(SalesType::Sales);
salesL.ItemId = item;
salesL.initFromInventTable(InventTable::find(_lensid));
salesL.SalesQty = qty;
salesL.PriceUnit = price ;
salesL.SalesPrice = qty * price;
salesL.createLine(1,1,0,1,1);
salesL.initFromInventTable(InventTable::find(_lensid));
salesL.SalesQty = qty;
salesL.PriceUnit = price ;
salesL.SalesPrice = qty * price;
salesL.createLine(1,1,0,1,1);
#############################################