Auto post item journal with spesific journal batch name

Hi Expert,

I am trying to do like "auto post" with specific journal Batch name. and I see that the code for posting in item journal like 3 lines below


CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",Rec);
CurrentJnlBatchName := GETRANGEMAX("Journal Batch Name");
CurrPage.UPDATE(FALSE);

and when I test and debug it, it show error since that the "Journal Batch Name" = ''

and I need to push some value in that batch name. how to do so ?

thanks,

Answers

  • vaprogvaprog Member Posts: 1,140
    Journal pages are designed to run for a specific template. Withing the page you can choose a batch belonging to that template. The page sets filters for the selected template name and batch name.

    For auto posting, you usually post journal line by journal line, not a whole batch, by just filling in the data needed, without inserting it into the table. In this case you leave template name and batch name fields blank.

    You may however, fill in a batch and post the whole batch using the appropriate codeunit ("Item Jnl.-Post Batch" in this case). Either make sure the batch is empty before you fill it, or else filter the batch such, that only your inserted lines are visible within the filter when you post it.

    If you need to post within a certain batch, follow the second path:
    • Insert into the batch,
    • make sure only those lines you want to post are within the filter,
    • call the batch post codeunit to post.
Sign In or Register to comment.