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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Create multiple Item Journal Lines & POST them in a Single Click

(0) ShareShare
ReportReport
Posted on by 1,144

Dear Sir,

I create multiple Item Journal Lines (For Re-class) from a Custom Document(QC) & want to Post them in a Single click. My Pseudo is given below for your review. Also I want that my QC Document will be Posted (transfer data from one(QC) to another (Posted QC)) after successfully Posting all the Lines from QC Document.  

It's my experience that the Codeunit Item Jnl.-Post Batch (ID 23) is useful for bulk posting if I call INSERT Function during ItemJournalLine Creation. But the Standard Code of that Codeunit will show few message before & after the Posting Which I don't want, even I don't want to manipulate any code of that Codeunit (ID 23) as well as can't call INSERT function in my Custom Code.

CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",ItemJournalLine); //ItemJournalLine - Table ID 83, Item Journal Line

I have also checked with the Codeunit Item Jnl.-Post Line (ID 22) to call repetitively in my custom code. 
And I have few doubt about the rollback system in this way. Suppose I have to post three Line (Item Journal Line) & there is some problem in the last Item Journal Line for which the last line can not be posted. If this will happen then I just want to know the first two line will be rollbacked defiantly ?

HeaderTable.GET
IF HeaderLine.FINDSET THEN BEGIN
  REPEAT
     IF HeaderLine.Field >0 THEN BEGIN
       CreateItemJournalLine(HeaderLine);
       ItemJnlPostLine.RunWithCheck(ItemJournalLine); //ItemJnlPostLine Codeunit Item Jnl.-Post Line (ID 22)
     END;
      IF HeaderLine.Field2 >0 THEN BEGIN
       CreateItemJournalLine2(HeaderLine);
       ItemJnlPostLine.RunWithCheck(ItemJournalLine); //ItemJnlPostLine Codeunit Item Jnl.-Post Line (ID 22)
     END;
  UNTIL HeaderLine.NEXT =0;
  //Create History BEGIN
   PostedHeaderTable
   PostedHeaderLine
  //Create History END
  //Delete BEGIN
    HeaderTable.DELETEALL;
    HeaderLine.DELETEALL;
  //Delete END
   Message('Posted Successfully');
END;

Kindly share your best suggestion.

Thanks,

Subrata

*This post is locked for comments

I have the same question (0)
  • Verified answer
    I Gusti Made Ari Profile Picture
    3,608 on at

    Looking at your code  , it will be rolled back if any error during posting the line.

    After all process completed and before the Message prompt  , i suggest to put commit command

    //Delete BEGIN

       HeaderTable.DELETEALL;

       HeaderLine.DELETEALL;

     //Delete END

      COMMIT; //add commit

      Message('Posted Successfully');

    this to avoid locking if user didn't close the message prompt.

  • subrata.bauri Profile Picture
    1,144 on at

    Thanks for you reply.  

    Exactly.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans