This is a sample Example of Code to create Free Text Invoice in Ax 2012. Variables you need to declare to complete code.
ttsBegin;
select custTable
where custTable.AccountNum == '123';
custInvoiceTable.clear();
if (custTable.RecId != 0)
{
custInvoiceTable.OrderAccount = custTable.AccountNum;
custInvoiceTable.modifiedField(fieldNum(CustInvoiceTable, OrderAccount));
custInvoiceTable.InvoiceId ='test04';
custInvoiceTable.insert();
lineNum = 0;
}
if (custInvoiceTable.RecId != 0)
{
custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);
// LedgerDimension=Dimensionstorage::accountNum2LedgerDimension("30104000",LedgerJournalACType::Ledger);
custInvoiceLine.LedgerDimension = LedgerDimension2;//5637146102;
custInvoiceLine.Description = '';
custInvoiceLine.TaxGroup = '';
custInvoiceLine.TaxItemGroup = '';
custInvoiceLine.Quantity = 0;
custInvoiceLine.UnitPrice = 0;
custInvoiceLine.AmountCur = 0;//customerInvoices.Quantity * customerInvoices.UnitPrice;
custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
custInvoiceLine.ItemCodeId="";
lineNum += 1;
custInvoiceLine.LineNum = lineNum;
custInvoiceLine.insert();
}
ttsCommit;
Comments