Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

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

Categories:
  • 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
    sohaibcheema Profile Picture
    sohaibcheema 46,594 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.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

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

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans