Friday, June 22, 2018

AX 2012 List page multi select datasource records AX2012

There may be situation to select multiple records in the list page and send it to other class to do some operation on the selected records. Below code will help you handle the same.

Step 1: Create new List page / Use the existing list page

Step 2 : Add menu item button in the list page  (For this example, you added an action menu item to call a class)

Step 3 : Choose the Multi select property to 'Yes'

Step 4 :  In the main method of the called class, Initialize the FormRun object.

 FormRun formRun;

 formRun = args.caller();


Step 5 : Initialize FormDatasource object to get the active records from the List page.

FormDatasource fds;

fds = formRun.pageInteraction().page().activeRecord('ListPageDataSourceName').dataSource();

Step 6 : Fetch the records that are marked in the list page

Common record;
CustTable custTable;

for (record = getFirstSelection(fds); record; record = fds.getNext())
{    
     custTable = record;
}


Best Regards,
Arun S Keerthi

AX 2012 Get Next Continuous Voucher number through X++ AX2012

Below job will help to get the next voucher number for continuous number sequence marked.


static void _updateVoucher(Args _args)
{
    NumberSeq numberSeq;
    NumberSequenceTable numSeqTable;
    Voucher voucher;

   
    numberSeq = NumberSeq::newGetVoucherFromId(LedgerJournalName::find('JournalName').NumberSequenceTable, true, false, UnknownNoYes::No);   
    info(numberSeq.voucher());
    numberSeq.used();
   
}