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

Announcements

No record found.

Community site session details

Community site session details

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

How to create Voucher number while inserting into inventJournalTrans

(2) ShareShare
ReportReport
Posted on by 80
Hi All, 

     I am  inserting records into "inventJournalTrans" in batch job, but i am stuck at how to create voucher number while inserting records into inventJournalTrans table.
Any help or suggestion. The is my code.
 
InventJournalTrans inventJournalTrans;
EntAssetParameters parameters  = EntAssetParameters::find();
JournalTableData    journalTableData;
JournalTransData    journalTransData;
inventJournalTrans.clear();
inventJournalTrans.initValue();
inventJournalTrans.initFromInventJournalTable(EntAssetWorkOrderTableJournals::findOrCreateInventJournalTable(_workOrderTable.RecId));
inventJournalTrans.TransDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());   
   
inventJournalTrans.EntAssetWorkOrderLine = _workOrderLine.RecId;
inventJournalTrans.ProjCategoryId = parameters.ItemCategory;

  //  inventJournalTrans.Voucher =
inventJournalTrans.JournalId = _inventJournalTable.JournalId;
inventJournalTrans.ItemId = _stagingLine.ItemId;
inventJournalTrans.Qty    = _stagingLine.Qty;
inventJournalTrans.insert();
 
Categories:
I have the same question (0)
  • Diego Mancassola Profile Picture
    603 on at
    Hello, what's your business requirement to do that?
     
    Tipically you don't have to set the voucher, the system set it for you based on journal name settings.
     
  • Suggested answer
    Manikanda_Gopal Profile Picture
    81 on at

    Hi Chranch,

    As Diego mentioned, the voucher number will be generated based on your respective inventory journal name. Please initialize your inventory journal name table (InventJournalName), then apply similar logic to populate the voucher number in the InventJournalTrans table.


    NumberSeq                     numberSeq = NumberSeq::newGetVoucherFromId(inventJournalName.VoucherNumberSequenceTable); // Pls note this method has optional parameters, verify carefully based on your scenario and number sequence setup
     
    inventJournalTrans.voucher = numberSeq.voucher();
     
    Please test this on your dev machine and mark it as the suggested answer if it works.
  • charanch Profile Picture
    80 on at
    Hi @Diego Mancassola and @Manikanda Gopal thanks for replying to my query.

           we are doing some integration, external party will send work order and work order journal related data, we are creating this work order journal in batch, so the entire journal creation and posting done in batch, while posting for every record need to generate voucher right. I'm new to integration , in fact this is my first working for integration.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 586 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 311

#3
Diego Mancassola Profile Picture

Diego Mancassola 271

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans