Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Invent Journal Transfer - After Post Method

Posted on by Microsoft Employee

Good Morning,

I have to insert in a custom table, data from an invent journal transfer, but I need to insert in that table after the journal is posted.

I found the  InventJournalCheckPost  class, that is called from the post button (InventJournalTransfer Form), but I don't know where to put my code to insert data to that custom table.

 

Please could you tell me where can I put some extra code, after the journal transfer is successfully posted?

 

Thansk a lot

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Invent Journal Transfer - After Post Method

    Brandon thank you very much

    It worked perfecly!

       InventJournalTable orig = this.orig();

       super();

       if( this.JournalType == InventJournalType::Transfer)

       {

           if (this.Posted && !orig.Posted)

           {

               //insert code

           }

       }

  • Verified answer
    Brandon Wiese Profile Picture
    Brandon Wiese 17,786 on at
    RE: Invent Journal Transfer - After Post Method

    May I suggest that you check specifically for when Posted is true and was just changed from false?  Otherwise you might see additional updates to the record creating more records in your secondary table than you like.

    For example, in the declaration section, add

    InventJournalTable orig = this.orig();

    Then, in your code block,

    if (this.Posted == true && orig.Posted == false)

    Or, more simply since the field is boolean,

    if (this.Posted && !orig.Posted)
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Invent Journal Transfer - After Post Method

    Thank you both!, Brandon and Sohaib,

    It worked perfectly!

    //on table  InventJournalTable

    public void update()

    {

       super();

       if( this.JournalType == InventJournalType::Transfer )

       {

           if( this.posted == NoYes::Yes )

           {

               // code to insert into custom table

           }

       }

    }

  • Verified answer
    Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Invent Journal Transfer - After Post Method

    Moreover, add an IF:-

    if(JournalType == InventJournalType::Transfer)

    {

    // add data in my custom table

    }

  • Verified answer
    Brandon Wiese Profile Picture
    Brandon Wiese 17,786 on at
    RE: Invent Journal Transfer - After Post Method

    InventJournalCheckPost does not actually do much work.  It's the InventJournalCheckPost_Movement class you're probably interested in.

    Since it inherits from JournalCheckPostLedger, which inherits from JournalCheckPost, to understand this class requires a bit of digging.

    Basically, the journal header gets marked as posted in runPostEnd(), so anything after the super() in that method on InventJournalCheckPost_Movement should work.  Also the runEnd() method follows runPostEnd(), so there is a good place.  You will have to override these in the InventJournalCheckPost_Movement class.

    Alternately, you could just add your code to InventJournalTable in the update() method, checking for the Posted field to turn Yes, and then add your record there, and that might just be easier all around.

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