web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to prevent a journal from posting

(0) ShareShare
ReportReport
Posted on by 455

Hi,

I am having a difficult time converting a AX 2012 customization to work the same in D365. We have some validation code on the Post journal clicked method in AX that if certain condition is met then it throws an error and halts the execution of the posting process. 

I tried CoC and Event handler but I just cant stop the posting. With CoC I run my validation first on the clicked method then compiler throw error that next call must be run unconditionally, if i create a event handler for OnClicked event it first run the super() method that result in running posting before my handler code.

Any suggestions/ideas?

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to prevent a journal from posting

    Hi Samy123,

    Could you please share your code in AX 2012 and in which form you had it? It will be helpful in determining where we could use it in D365 F&O.

  • Samy123 Profile Picture
    455 on at
    RE: How to prevent a journal from posting

    Form: ProdJournalTable

    Button: Post, method: Clicked()

    Custom code is before call to super()

    ProdJournalBOM      prodJournalBOM;

    while select prodJournalBOM

               where prodJournalBOM.JournalId == prodJournalTable.JournalId

       {

           if(prodJournalBOM.TransDate > today())

           {

               error("Posting error");

              return;

           }

       }

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to prevent a journal from posting

    Hi Samy123,

    CoC should work fine if you still want the validation logic in the clicked method. Please share the code you tried for CoC. Maybe we can see the issue there.

    It might be better if you move the validation to ProdJournalCheckPost class.

  • Deepak Agarwal Profile Picture
    8,585 on at
    RE: How to prevent a journal from posting

    You can give a try to hide the button itself on active method of form. Use COC and extend the active method of form.

  • Verified answer
    Martin Dráb Profile Picture
    236,297 Most Valuable Professional on at
    RE: How to prevent a journal from posting

    Putting such logic to clicked() is a bad idea. Journals posting already support validation, you can even run validation without posting to check if data in the journal is all right. You sholuld add your logic there.

    Look at check* methods in ProdJournalCheckPost, e.g. checkProdTable().

  • Samy123 Profile Picture
    455 on at
    RE: How to prevent a journal from posting

    Thanks Martin! this seems to be the best way of achieving it., In AX we were spoiled and used to take shortcuts to get things done :) D365 is more strict on that.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,167

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 867 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 617 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans