26 April 2016

Pass the record from to class in ax 2012

LedgerJournalTable Form Button:

void clicked()
{
Args args = new Args();
VendInvoiceJournalLineImport invoicejournalimport
;
args.record(LedgerJournalTable);
invoicejournalimport = new VendInvoiceJournalLineImport();
invoicejournalimport.run(args);
LedgerJournalTrans_ds.executeQuery();
}

Class:

public void run(Args _args)
{
ledgerJournalTable = _args.record() as ledgerJournalTable;
dialog = new dialog('Excel Import');

dialogfield = dialog.addField(extendedTypeStr(FilenameOpen), 'File Name');
dialog.run();
if(dialog.run())
{
filename = (dialogfield.value());
application = SysExcelApplication::construct();
workbooks = application.workbooks();
if(filename)
{
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error('File cannot be opened.');
}
this.dataImport();
}
}
}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...