Skip to main content

Notifications

Announcements

No record found.

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

  • subrata.bauri Profile Picture
    1,144 on at
    RE: Create multiple Item Journal Lines & POST them in a Single Click

    Thanks for you reply.  

    Exactly.

  • Verified answer
    I Gusti Made Ari Profile Picture
    3,594 on at
    RE: Create multiple Item Journal Lines & POST them in a Single Click

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans