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 AX (Archived)

Retrieve sales invoice journals when posting in batch

(0) ShareShare
ReportReport
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

  • Verified answer
    Seeker Profile Picture
    25 on at

    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.

  • Oksana Tsionel Profile Picture
    44 on at

    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?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans