Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Retrieve sales invoice journals when posting in batch

Posted on by 25

Hi, I'm performing some post invoice posting activities and having some issues.

The way I'm doing it is by attaching an post type event handler on SalesFormLetter_Invoice.afterOperationBody() where I basically do:

SalesFormLetter_Invoice salesFormLetter_Invoice = _ppArgs.getThis();
salesFormLetter_Invoice.getOutputContract().parmAllJournals();

With this I can iterate and perform my tasks on the posted invoices.

This works fine when posting invoices manually, in batch on the client but not when doing it in batch on the server.

The set returned by parmAllJournals (or rather base64 encoded string) is empty and I've tried a few other ways such as:

custInvoiceJour = salesFormLetter_Invoice.parmJournalRecord() as CustInvoiceJour;
    
custInvoiceJour = salesFormLetter_Invoice.getSalesFormLetterContract().parmJournal() as CustInvoiceJour;

But I'm not getting any journals.
I've gone through a great deal of code down to Sysop framework trying to figure it out but I can't find anything obvious.

Did anyone else struggle with this?

Thanks

*This post is locked for comments

  • Oksana Tsionel Profile Picture
    Oksana Tsionel 44 on at
    RE: Retrieve sales invoice journals when posting in batch

    I am facing with the same issue. I looked in available variables when FormletterServiceMultithread.endPosting() is executed but corresponding formLetterOutputContract does not have "AllJournals" populated as well.

    Would it be possible to share the full code that allows to get "AllJournals" when invoices are posted via batch?

  • Verified answer
    Seeker Profile Picture
    Seeker 25 on at
    RE: Retrieve sales invoice journals when posting in batch

    I found a way to do it, basically the salesFormLetter isn't used the same way in batch as when done manually so I added my event handler on FormletterServiceMultithread.endPosting() as well as some code to determine where it was called from:

       if(thisRef is SalesFormLetter_Invoice)
       {
           salesFormLetter_Invoice = thisRef;
           formletterOutputContract = salesFormLetter_Invoice.getOutputContract();
       }
    
       else if(thisRef is FormletterServiceMultithread)
       {
           formletterService = thisRef;
           formletterOutputContract = formletterService.getOutputContract();
       }

    Note that you also have to check the journal type as this will be used for all types of journals posted in batch, as in my case I had to check for CustInvoiceJour. Might not be the neatest solution, but it does work.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,336 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans