web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Get next Journal batch number for 'Payroll' and voucher from its series

(0) ShareShare
ReportReport
Posted on by 290
 
 
IN Dynamics 365 for Finance and Operations X++
 
 

Body:

I’m on Dynamics 365 Finance & Operations X++. I expose a custom service that creates a General Journal for a specific journal name Payroll. Before/while creating the journal, I want to:


  1.  

    How Read (or safely generate) the Journal batch number (LedgerJournalTable.JournalNum) that will be assigned to the header for journal name Payroll.


  2.  

    How Read (or safely generate) a Voucher number for the journal lines based on the voucher series configured on the same journal name.

 

I’m looking for short sample.

 
 
 
 
 
 
 
 
I’m looking for short sample.
 
 
 
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,043 Most Valuable Professional on at
    Get next Journal batch number for 'Payroll' and voucher from its series
    There are standard classes that will help you with that; you don't need to touch the number sequences on your own.
     
    Assing journal number:
    LedgerJournalName journalName = LedgerJournalName::find(...);
    LedgerJournalTable journal;
    journal.initFromLedgerJournalName(journalName.JournalName);
    journal.JournalNum = JournalTableData::newTable(journal).nextJournalId();
    Assign voucher number:
    JournalVoucherNum journalVoucherNum = new JournalVoucherNum(JournalTableData::newTable(journal));
    
    LedgerJournalTrans ledgerJournalTrans;
    ...
    ledgerJournalTrans.Voucher = journalVoucherNum.getNew(false);
  • Sohaib Cheema Profile Picture
    48,213 User Group Leader on at
    Get next Journal batch number for 'Payroll' and voucher from its series
    + on thing you must remember that when it comes to voucher number on lines, you must not be surprised by the voucher number behaving different. If your third party app people talk about it, they should know that it can be a different number based on setup.
     
    As for any normal sequence , it could be as retrieved as follows 
     
    NumberSequenceReference numberSequenceReference = NumberSeqReference::findReference(extendedtypenum(YourEDT));
    NumberSeq journalNumberSeq = NumberSeq::newGetNum(numberSequenceReference, false);
     
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    298,154 Super User 2025 Season 2 on at
    D365FO X++: Get next Journal batch number for 'Payroll' and voucher from its series
    Hi,
     
    How to draw a new number from a number sequence is done with help of the class NumberSeq. There are various methods, where newGetNum is the most common one. You can find a lot of examples in the standard application on how to use this class and the method. To find places where it is used, you can search for the references using the cross reference tools.
     
    For journal lines, it is similar. You can also consider using a temporary number sequence that will be replaced with the actual voucher number upon posting. Read more on my blog about this option: What is the temporary voucher functionality in Dynamics 365?  
  • Mansi Soni Profile Picture
    8,753 Super User 2025 Season 2 on at
    D365FO X++: Get next Journal batch number for 'Payroll' and voucher from its series
    Moved from Dynamics 365 General forum to Finance forum.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 895

#2
Sohaib Cheema Profile Picture

Sohaib Cheema 811 User Group Leader

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 787 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans