Skip to main content

Notifications

Small and medium business | Business Central, N...
Unanswered

Posting to multiple item reclass journals

Posted on by
Hi there,
I'm working on an extension to add lines to our item reclass journals. I am using the default /Item Reclass. Journal/ page to add the items and run a codeunit to call /Item Jnl.-Post Batch/ separately to post the batch. This all works as long as my user stays on the same batch. If I post items through the API to the current journal, all goes well. If I post to a journal that is not currently selected, then I get the error: 
The Item Journal Batch does not exist. Identification fields and values: Journal Template Name='TRANSFER',Name='' 
 
I have tried setting a filter on the Item Journal Line to the new batch and have run a codeunit to run ItemJnlManagement with an Item Journal Batch record set to the correct batch. Nothing seems to set the environment like opening the page, then running the API.
 
Here is the code I've tried to run immediately before posting the new record to the page:
procedure PostReclass(batchName: text; postItems: Boolean): Text    var        lrRec: Record /Item Journal Batch/;    begin        lrRec.Init();        lrrec.SetFilter(Name, batchName);        //lrRec.SetFilter(/Journal Batch Name/, batchName);        Codeunit.Run(codeunit::ItemJnlManagement, lrRec);        if lrRec.FindFirst() and postItems = true then begin            //repeat            CODEUNIT.RUN(CODEUNIT::/Item Jnl.-Post Batch/, lrRec);            //until rec.next = 0        end;        exit(lrRec.Name);    end;
 
then call 
the Journal_Batch_Name I'm passing in Json matches the batchName passed above and is a valid batch; yet it complains that there is no valid batch. Any help would be greatly appreciated!
Categories:

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans