X++ code to generate ledger voucher number sequence in AX 2012 & D365
NumberSeq numberSeq;
NumberSequenceTable numSeqTable;
Voucher voucher;
select firstOnly numSeqTable
where numSeqTable.RecId == LedgerJournalName::find(ledgerJournalTable.JournalName).NumberSequenceTable;
if (numSeqTable && !voucher)
{
numberseq = numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
voucher = numberseq.voucher();
}
ledgerJournalTrans.Voucher = voucher;
Thanks & Regards
Sindhu